pm2

What is the difference between pm2 restart and pm2 reload

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a nodejs app running on server. When should I use pm2 restart ,and when should pm2 reload be used? Referred to the pm2 documention here,but couldn't figure out the difference in use case of the two. 回答1: The difference is documented here : As opposed to restart , which kills and restarts the process, reload achieves a 0-second-downtime reload. The latter means (found here ): With reload, pm2 restarts all processes one by one, always keeping at least one process running. It also states that: If the reload system hasn’t managed to

Cluster and Fork mode difference in PM2

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I've searched a lot to figure out this question, but I didn't get clear explanation. Is there only one difference thing that clustered app can be scaled out and forked app cannot be? PM2's public site explains Cluster mode can do these feature but no one says about pros of Fork mode (maybe, it can get NODE_APP_INSTANCE variable). I feel like Cluster might be part of Fork because Fork seems like to be used in general. So, I guess Fork means just 'forked process' from the point of PM2 and Cluster means 'forked process that is able to

Is there a way to restart pm2 process using cron but only if it's not already running?

匿名 (未验证) 提交于 2019-12-03 00:48:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to restart my Node.Js app using PM2 through pm2 restart app.js using crontab but ONLY if the app is not already running (e.g. if my server crashed and restarted and pm2 didn't restart). the command above restarts it anyway even if it's running. How do I fix it? UPDATE I do not want my app to restart if it's already running. I want it to restart only if it's listed as "stopped" or if it is not running. Some suggestions offer to write a bash script, but what would it be? I tried the options below, but they either don't work or restart

pm2用法之ecosystem部署nodejs

匿名 (未验证) 提交于 2019-12-03 00:37:01
在项目根目录添加 pm2 的部署脚本文件 ecosystem.json { "apps" : [ "name" : "movie" , //对应Nginx上的配置 "script" : "app.js" , //入口文件 "env" : { "COMON_VARIABLE" : "true" }, "env_production" : { "NODE_ENV" : "production" } ], "deploy" : { "production" : { "user" : "poetries" , //Nginx服务器上的username "host" : [ "120.120.14.21" ], // 服务器地址 "port" : "3922" , "ref" : "origin/master" , //从指定的分支拉取代码 "repo" : "git@github.com:poetries/poetries.github.io.git" , "path" : "/www/movie/production" , //发布到服务器指定的目录下 "ssh_options" : "StrictHostKeyChecking=no" , //构建在发布 "post-deploy" : "npm install --registry=https://registry.npm

Node搭建多人聊天室

匿名 (未验证) 提交于 2019-12-02 23:47:01
博客初期准备使用的通讯,后被荒废。 使用的是nodejs-websocket,未使用socket.io 用来玩玩的东西,了解下通讯协议。 演示地址: git地址: https://github.com/Amayaliu/AmayaChatRoom.git 博客地址: Amayaliu.cn 运行后,即可打开index.html文件浏览,亦可打开 127.0.0.1:4399 端口访问,对话可选择多打开几个 服务器部署: 首先把 app.js 文件部署到服务器,服务器 需安装node 安装pm2并启动nodejs的项目 展开pm2服务器部署步骤

pm2入门

匿名 (未验证) 提交于 2019-12-02 23:45:01
简介 PM2是node进程管理工具,可以利用它来简化很多node应用管理的繁琐任务,如性能监控、自动重启、负载均衡等,而且使用非常简单。 安装 全局安装,简直不能更简单。 npm install -g pm2 目录介绍 pm2安装好后,会自动创建下面目录。看文件名基本就知道干嘛的了,就不翻译了。 - $HOME/.pm2` will contain all PM2 related files - `$HOME/.pm2/logs` will contain all applications logs - `$HOME/.pm2/pids` will contain all applications pids - `$HOME/.pm2/pm2.log` PM2 logs - `$HOME/.pm2/pm2.pid` PM2 pid - `$HOME/.pm2/rpc.sock` Socket file for remote commands - `$HOME/.pm2/pub.sock` Socket file for publishable events - `$HOME/.pm2/conf.js` PM2 Configuration 常用命令总结: 启动 参数说明: --watch:监听应用目录的变化,一旦发生变化,自动重启。如果要精确监听、不见听的目录,最好通过配置文件。

JenKins使用pm2部署.net core网站

匿名 (未验证) 提交于 2019-12-02 22:06:11
登录事先准备好的 Jenkins 1 新建任务 2 源码管理 git 输入正确地址 3 构建环境: Delete workspace before build starts Abort the build if it's stuck 打勾 4 安装事先准备好的 pm2 打开shell安装 https://www.cnblogs.com/stulzq/p/9775973.html sudo yum install nodejs node -v npm install pm2 -g 5 回到Jenkins 选择 构建=>执行shell ls cd ./VPStest.netCore/VPStest.netCore ls dotnet publish -c Release cd bin/Release/netcoreapp2.2/publish ls pm2 start "dotnet VPStest.netCore.dll" --name testweb 6 保存 选择立即构建 7 查看控制台输出 Started by user www Building in workspace /var/lib/jenkins/workspace/DotCoreTest [WS-CLEANUP] Deleting project workspace... [WS-CLEANUP] Deferred

linux下安装pm2 pm2: command not found

匿名 (未验证) 提交于 2019-12-02 21:59:42
安装后可能报一些warn 不用管。 pm2: command not found 原因是pm2没有配置到全局变量中,添加软连接可以解决 安装后能看到pm2安装位置,见下图: 执行命令 ln -s /root/node-v10.2.0-linux-x64/bin/pm2 /usr/local/bin/ 注意上面的命令中中间的路径为你node的安装位置 pm2 -v查看 出息版本号即成功 文章来源: linux下安装pm2 pm2: command not found

Start app as root with pm2

点点圈 提交于 2019-12-02 20:26:19
I have a daemon that must be run as root on startup. I use pm2 to start other apps but can not figure out if it can start an app as root. Can it be done? If not, what are my options? I had problems with sudo pm2 start api , but this was since pm2 was already running without sudo privileges, therefor you need to run: pm2 kill sudo pm2 start api This kills the pm2 deamon first, so that it starts in sudo, but then you need sudo for ALL pm2 commands afterwards, like: sudo pm2 ls If you only need your daemon to be run as root in order to access a port number (such as 80 or 443), the pm2

How to make a cron job with PM2

空扰寡人 提交于 2019-12-02 18:13:01
I want to make a cron job to send mail every 15 minutes taking data from a database table. In node js I can make a cron job but through PM2 I don't understand where to place the code and how it works. Use the --cron option: -c --cron <cron_pattern> For example: pm2 start sendMail.js --cron "*/15 * * * *" Pm2 will now restart the sendMail.js script on the hour, and at 15, 30 and 45 minutes past the hour If you use PM2 ecosystem then in the config file add cron sequence to script param by wrapping it with single quotes. Somehow double quotes didn't work for me. module.exports = { apps : [{ name