zoukankan      html  css  js  c++  java
  • Node.js——PM2命令

    npm install pm2 -g
    pm2 update

    附pm2命令:

    $ npm install pm2 -g     # 命令行安装 pm2 
    $ pm2 start app.js -i 4  # 后台运行pm2,启动4个app.js 
                             # 也可以把'max' 参数传递给 start
                             # 正确的进程数目依赖于Cpu的核心数目
    $ pm2 start app.js --name my-api # 命名进程
    $ pm2 list               # 显示所有进程状态
    $ pm2 monit              # 监视所有进程
    $ pm2 logs               # 显示所有进程日志
    $ pm2 stop all           # 停止所有进程
    $ pm2 restart all        # 重启所有进程
    $ pm2 reload all         # 0 秒停机重载进程 (用于 NETWORKED 进程)
    $ pm2 stop 0             # 停止指定的进程
    $ pm2 restart 0          # 重启指定的进程
    $ pm2 startup            # 产生 init 脚本 保持进程活着
    $ pm2 web                # 运行健壮的 computer API endpoint (http://localhost:9615)
    $ pm2 delete 0           # 杀死指定的进程
    $ pm2 delete all         # 杀死全部进程



    The simplest way to start, daemonize and monitor your application is by using this command line:

    $ pm2 start app.js
    

    Or start any other application easily:

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

    Some options you can pass to the CLI:

    # 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
     

    Restart application on changes

    It’s pretty easy with the --watch option:

    $ cd /path/to/my/app
    $ pm2 start env.js --watch --ignore-watch="node_modules"


    参考:
    https://pm2.keymetrics.io/docs/usage/quick-start/ 
  • 相关阅读:
    从 java 代码到 android 进程的详细过程
    c++ 智能指针
    linux 进程间共享内存示例
    visual studio 在windows远程调试 linux 程序 cout 输出乱码
    wcf restful 访问报错 *.svc HTTP error 404.17
    c++ 创建 uuid guid
    c++ 事件回调 java
    java通过jna调用so
    java执行jar包
    java调用com组件com4j
  • 原文地址:https://www.cnblogs.com/xingchong/p/13191081.html
Copyright © 2011-2022 走看看