pm2

node及pm2环境安装

℡╲_俬逩灬. 提交于 2019-12-06 16:31:30
一、node安装 软件地址: https://nodejs.org/en/download/ #1、下载软件包 [root@node ~]# mkdir /app [root@node ~]# cd /app/ [root@node app]# wget https://nodejs.org/dist/v12.13.1/node-v12.13.1-linux-x64.tar.xz [root@node app]# ll total 13740 -rw-r--r-- 1 root root 14067172 Nov 19 16:39 node-v12.13.1-linux-x64.tar.xz #2.解压缩 [root@node app]# tar xf node-v12.13.1-linux-x64.tar.xz -C /usr/local/ [root@node app]# cd /usr/local/ [root@node local]# ls bin etc games include lib lib64 libexec node-v12.13.1-linux-x64 sbin share src [root@node local]# mv node-v12.13.1-linux-x64/ node [root@node local]# ls bin etc games

How to use pm2 startup command on Debian platform?

 ̄綄美尐妖づ 提交于 2019-12-06 14:26:59
Here is the link to the documentation on GitHub: https://github.com/Unitech/pm2#startup-script-generation--pm2-startup It is setup to work with Ubuntu/CentOS/Redhat. I need it to work with my Dreamhost VPS which is a Debian machine. Can someone advise me on how I might tweak the init script to make it work on a Debian box? Thanks!! Try ubuntu solution. Since ubuntu is a debian fork, it should work there. If your vps is running the Jessie release (>8) then Jessie uses systemd not init.d (as ubuntu and older releases of debian do). Thus using the default ubuntu pm2 startup script won't work. So

bash: pm2: command not found

你离开我真会死。 提交于 2019-12-06 14:22:04
I can't run pm2 on ubuntu box. I'm not sure what's the problem. The pm2 is installed globally. npm list -g --depth=0 /opt/nodejs/lib ├── forever@0.15.3 ├── node-gyp@3.4.0 ├── npm@2.15.9 ├── pm2@2.1.5 ├── userdown@0.2.1 └── wait-for-mongo@0.2.0 But I still get pm2 -bash: pm2: command not found if I run other app userdown Starting Script is not provided versions node v4.5.0 npm v2.15.9 log from installation: sudo npm install pm2 -g npm WARN optional dep failed, continuing fsevents@1.0.15 /opt/nodejs/bin/pm2 -> /opt/nodejs/lib/node_modules/pm2/bin/pm2 /opt/nodejs/bin/rundev -> /opt/nodejs/lib

How to run “npm install” before every pm2-restart?

点点圈 提交于 2019-12-05 20:02:35
I am trying to automatically deploy a hobby-node-app to my Raspberry Pi 2 via PM2. The PM2 package "autopull" automatically pulls the latest commit from the checked out branch of my Bitbucket-Repo (in case of the RBPi 2 -> master) and restarts PM2. However, if I add new dependencies in my bower.json or package.json in the latest commit, those would not be installed by PM2. Is there a way to have PM2 automatically run "npm install && bower install" after every git pull? I would also be satisfied with a different setup that would achieve the same thing. Try a git hook! Put this inside your repo

nodejs PM2 cluster mode for load balancing

匆匆过客 提交于 2019-12-05 19:52:32
When using pm2 cluster there's a pretty severe warning saying you shouldn't use it in production, nor for load balancing, use nginx instead. Unfortunately that's exactly how I planned to use PM2. Is it really not intended to be used for that purpose or is it just not completely ready yet? The nodejs cluster (0.10) has a lot of issues and is not safe to use in production! You may want to give a try with 0.11, there were some improvements. This feature has not anything to do with pm2, it's in fact directly related to node cluster module . 来源: https://stackoverflow.com/questions/28083959/nodejs

PM2 and Nginx: 502 Bad Gateway

非 Y 不嫁゛ 提交于 2019-12-05 16:34:06
I've been trying to deploy my Node project on a brand new DO droplet, but i'm having some problems with PM2. My steps are a follows: Node came installed on the Droplet image (Ubuntu, Node v4.4.4) Installed PM2 globally Setup Nginx to reverse proxy 127.0.0.1:3000 Cloned my project and did npm install All i get is Nginx complaining about a 502 Bad Gateway. If i look at the Nginx error.log i get this: connect() failed (111: Connection refused) while connecting to upstream, client: client.ip , server: my.server , request: "GET / HTTP/1.1", upstream: " http://127.0.0.1:3000/ ", host: " my.server "

PM2 on vagrant - starting app AFTER shared folder is mounted

早过忘川 提交于 2019-12-05 14:36:57
How can I set PM2 to start the app after the shared directories get mounted? By default pm2 startup adds script which try to run script right after OS boot, which causes program error (because the folder is not yet mounted by that time). you can add the following line in your Vagrantfile config.vm.provision :shell, :inline => "pm2 start /vagrant/project/server/index.js && pm2 startup", :run => 'always', privileged: false read about shell provisioning : inline (string) - Specifies a shell command inline to execute on the remote machine. This is where you will enter the command lines as you

nodejs服务后台持续运行三种方法

拈花ヽ惹草 提交于 2019-12-05 11:24:54
一、利用 forever forever是一个nodejs守护进程,完全由命令行操控。forever会监控nodejs服务,并在服务挂掉后进行重启。 1、安装 forever npm install forever -g 2、启动服务 service forever start 3、使用 forever 启动 js 文件 forever start index.js 4、停止 js 文件 forever stop index.js 5、启动js文件并输出日志文件 forever start -l forever.log -o out.log -e err.log index.js 6、重启js文件 forever restart index.js 7、查看正在运行的进程 forever list 二、pm2是一个进程管理工具,可以用它来管理你的node进程,并查看node进程的状态,当然也支持性能监控,进程守护,负载均衡等功能 npm install -g pm2 pm2 start app.js // 启动 pm2 start app.js -i max //启动 使用所有CPU核心的集群 pm2 stop app.js // 停止 pm2 stop all // 停止所有 pm2 restart app.js // 重启 pm2 restart all // 重启所有 pm2

Debug application which is run using pm2

醉酒当歌 提交于 2019-12-05 09:14:41
问题 Application is run by pm2 start app.js or pm2 start config.json I want to debug my application locally using node_inspector. I added debug argument pm2 start --node-args="--debug=7000" app.js It works fine but if I provide config.json instead of script app.js I don't know how to pass arguments about debug. Next piece of config doesn't work { "apps": [ { "name": "myName", "script": "app.js", "args": "['--debug=7000']" ............ } ] } So How to debug application which is run by pm2 and using

Is there a way or a trigger to notify when there is an error and restart happened with PM2

别说谁变了你拦得住时间么 提交于 2019-12-05 08:41:16
I have an express application running and I am using PM2 to keep it alive and restart when there is any error in the system. PM2 logs the error and restarts which is perfectly fine. But I need to notify the user who submitted this with the error message. Is there any way or event or trigger which is activated when the restart happens or when the error is being written to the log file so that I can try to capture that and notify the actual user? I implemented as per suggestion below, var pm2 = require('pm2'); pm2.connect(function(err) { if (err) { console.error(err); process.exit(2); } console