zoukankan      html  css  js  c++  java
  • nodejs pm2守护进程使用

    pm2是一个守护进程管理器,它可以帮助你保持应用一直online.

    安装

    $ npm install pm2@latest -g
    # or
    $ yarn global add pm2

    Quick Start

    最简单的方式启动、守护、监视你的应用的方法:

    $ pm2 start app.js

    或者启动其他类型的应用:

    $ pm2 start bashscript.sh
    $ pm2 start python-app.py --watch
    $ pm2 start binary-file -- --port 1520

    一些其他的选项:

    # Specify an app name
    --name <app_name>
    
    # Watch and Restart app when files change
    --watch
    
    # Set memory threshold for app reload
    --max-memory-restart <200MB>
    
    # Specify log file
    --log <log_path>
    
    # Pass extra arguments to the script
    -- arg1 arg2 arg3
    
    # Delay between automatic restarts
    --restart-delay <delay in ms>
    
    # Prefix logs with time
    --time
    
    # Do not auto restart app
    --no-autorestart
    
    # Specify cron for forced restart
    --cron <cron_pattern>
    
    # Attach to application log
    --no-daemon

    管理进程

    $ pm2 restart app_name
    $ pm2 reload app_name
    $ pm2 stop app_name
    $ pm2 delete app_name

    检查状态和日志

    列出所有pm2管理的进程:

    $ pm2 [list|ls|status]

    打印日志:

    $ pm2 logs
    $ pm2 logs --lines 200

    pm2.io: 一个Web interface

    $ pm2 plus

    参考链接:https://pm2.keymetrics.io/docs/usage/quick-start/#welcome

  • 相关阅读:
    sql中的Bulk 导入txt文本
    通过SQL自动添加流水号
    JAVA XML格式化输出
    nginx 服务端口权限13的问题
    使用hangfire在xunit中
    自动提交代码
    系统性能测试
    前端性能——速度之书
    node fs相对路径
    yum 初始化国内
  • 原文地址:https://www.cnblogs.com/lfri/p/13289961.html
Copyright © 2011-2022 走看看