1

PM2守护方式启动nuxt项目

 3 years ago
source link: https://segmentfault.com/a/1190000040640676
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

1,修改package.json

{
  "name": "ii222",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt build && nuxt start",
    "generate": "nuxt generate"
  },
 // 以下省略
}

2进入到项目目录执行如下命令

pm2 start ./node_modules/nuxt/bin/nuxt.js

常用的PM2命令

pm2 list                       # 列表 PM2 启动的所有的应用程序
pm2 stop 0                     # 停止 id为 0的指定应用程序
pm2 restart 0                  # 重启id为0 的应用程序
pm2 delete 0                   # 删除指定应用 id 0



pm2 start app.js               # 启动app.js应用程序
pm2 start app.js --name="demo"  # 启动应用程序并命名为 "demo"
pm2 start app.js --watch       # 当文件变化时自动重启应用
pm2 start script.sh            # 启动 bash 脚本
pm2 show [app-name]            # 显示应用程序的所有信息
pm2 logs                       # 显示所有应用程序的日志
pm2 logs [app-name]            # 显示指定应用程序的日志
pm2 stop all                   # 停止所有的应用程序
pm2 restart all                # 重启所有应用
pm2 delete all                 # 关闭并删除所有应用
pm2 startup                    # 创建开机自启动命令
pm2 save                       # 保存当前应用列表

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK