3

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                       # 保存当前应用列表

Recommend

  • 16
    • 掘金 juejin.im 5 years ago
    • Cache

    pm2 实践指南

    前言 pm2 是 node 进程管理工具,可以利用它来简化很多 node 应用管理的繁琐任务,如性能监控、自动重启、负载均衡等,因为在工作中遇到服务器重启后,需要一个个去重新启动每个服务,这样不仅繁琐、效率低,而且容易遗忘开启一些服务,所以特地对 pm2 进行

  • 7
    • segmentfault.com 4 years ago
    • Cache

    pm2常见命令(1)

    pm2常见命令(1)发布于 今天 15:15 1.1 查看进程/应用的资源消耗情况pm2 monit阅读 23发布于 今天 15:15

  • 11
    • blog.singee.me 3 years ago
    • Cache

    pm2 + ts-node 的那些坑

    pm2 + ts-node 的那些坑 发表于 2020-11-06 Ecosystem File 按照如下写法 const fs = require("fs");let interpreter;if (process.platform === "win32") { interpreter = "/.bin/ts...

  • 12

  • 11

    新闻动态 COS 每周精选: PM2.5 的数据可视化 王威廉 / 冷静 / 蔡占锐 / 王小宁 编辑:王小宁...

  • 4

    7 September 2021 / Nuxt.js #nuxt.js docker镜像启动后无法访问 nuxt.js项目打包后,制作成docker镜像,映射默认端口3000到3000,启动以后,访...

  • 12

    Deploy Angular Project on an ubuntu server with pm2 1. Install NodeJs su...

  • 4
    • baozi.fun 3 years ago
    • Cache

    Windows 下安装 pm2

    原文链接:https://www.cnblogs.com/wanghaokun/p/10844872.html 安装pm2 npm install pm2 -g 添加系统环境变量 PM2_HOME=C:\Users\PCON...

  • 6

    先在服务器上实现远程git的免密登陆权限 生成一组SSH密钥 ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' -C "[email protected]" "[email protected]"是自己的绑定邮箱 将新生产的私钥生效

  • 4

    <?xml encoding="utf-8" ??>Introduction Node.js is a server-side JavaScript environment that can be used to create high-performance, real-time applications for the web and mobile devices. Managin...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK