pm2

Hitchhiker编译

纵饮孤独 提交于 2020-02-03 05:16:18
介绍 hitchhiker是一个开源软件,基于nodejs,以typescript语言编写的可视化的web接口文档、测试、压测的工具。支持导入、使用第三方js模块。 源码: https://github.com/brookshi/Hitchhiker 需要切换到 release 分支 编译环境 nodejs 版本要求7.60+,并更新npm到最新 npm install npm -g 。本人采用的8.9.4版本。 全局安装 可以参考 https://github.com/brookshi/Hitchhiker/blob/release/cn/installation/win.md 中的脚本链接 https://raw.githubusercontent.com/brookshi/Hitchhiker/release/deploy/win_deploy.bat 。使用 cnpm 吧,快很多。 cnpm install -g yarn gulp-cli gulp typescript@2.3.3 依赖安装 随着typescript版本的提高,一些默认导入的包的版本过高,导致正常编译报错,需要降低某些包的版本。 首先把版本中 ^ 全部去掉,只使用特定版本。 在package.json中的devDependencies里增加以下配置: "@types/connect": "3.4.32",

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

筅森魡賤 提交于 2020-02-02 03:50:08
问题 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 =

Graceful shutdown with nodejs pm2 SIGINT not working

两盒软妹~` 提交于 2020-01-25 10:13:10
问题 Hello I Have an application server written in js and is running on windows. Furthermore I'm using pm2 module but I have noticed that when I start my application server via pm2 start index.js -i 8 and then I want to stop all pm2 processes via pm2 stop all the event listeners for SIGINT are completely ignored... I should add that this works fine when used with plain node and not pm2. So I was wondering am I missing something obvious here? Bellow is a sample test source and pm2 docs const http =

Node.js/pm2 - Can't kill TCP connection

删除回忆录丶 提交于 2020-01-25 10:12:27
问题 I'm trying to use NordVPN like a standard web proxy by adding the proxy to the request options like so: const request = require('request-promise'); const options = { url: 'https://icanhazip.com', proxy: 'tcp://email@email.com:pass@us349.nordvpn.com', } const res = await request.get(options); // returns the NordVPN server ip address This works, however, NordVPN allows a maximum of 6 connections and when the proxy url is changed, the previous connection stays open. I see that I can run sudo

Node.js/pm2 - Can't kill TCP connection

谁说胖子不能爱 提交于 2020-01-25 10:12:06
问题 I'm trying to use NordVPN like a standard web proxy by adding the proxy to the request options like so: const request = require('request-promise'); const options = { url: 'https://icanhazip.com', proxy: 'tcp://email@email.com:pass@us349.nordvpn.com', } const res = await request.get(options); // returns the NordVPN server ip address This works, however, NordVPN allows a maximum of 6 connections and when the proxy url is changed, the previous connection stays open. I see that I can run sudo

How to require dotenv/config file on (before) PM2 starts

喜欢而已 提交于 2020-01-25 09:24:10
问题 I run node app like this: node -r dotenv/config dist/app I need something similar using PM2: pm2 start -r dotenv/config dist/app.js --name appname // doesn't work I receive the next error: error: unknown option -r 回答1: Using node_args. pm2 start --node-args="-r dotenv/config" dist/app.js --name appname 回答2: I have made a Shell script: // pm2-start.sh NODE_ENV=production && node -r dotenv/config dist/app Then I ran pm2 start pm2-start.sh --name appname Tip I have also ran: pm2 startup then

Can't stop node.js app started with pm2 process manager

丶灬走出姿态 提交于 2020-01-24 22:06:13
问题 I want to rebuild my node+vue.js app to update the changes I made. The app was started with pm2, but the problem is that I can't see anything when I do pm2 ls . The list is empty. On the other hand, the node app is running. I tried to kill it with pid, but it is restarting immediately. Any suggestions? 来源: https://stackoverflow.com/questions/52377977/cant-stop-node-js-app-started-with-pm2-process-manager

How to use pm2 to run grunt serve

∥☆過路亽.° 提交于 2020-01-24 19:55:22
问题 my colleague passed me a project that you run grunt serve to start. Now I'm trying to use pm2 to start the project in the background forever so I can close my command line. However, I couldn't find a right way to do it. I've seen answers like cd /path/to/fullstack pm2 start grunt --name website -- serve but I don't quite understand and I have very little knowledge regarding grunt. All I know is that grunt serve runs multiple tasks at the same time for me. I know that if I know the base js

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

半腔热情 提交于 2020-01-23 05:53:29
问题 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

Node.js getting SIGINT from pm2

删除回忆录丶 提交于 2020-01-14 13:59:28
问题 I'm trying to use pm2 to run my node app as a service. Right now, starting and stopping the app works. However, I want to do a graceful shutdown. My app already listens for SIGINT, shutdowns the server and then exits the process. However, trying to put pm2 to send the SIGINT, just causes the app to restart, like if pm2 was killing and starting it again. This is how I create the process: pm2 start server.js --name ProcessName --silent --kill-timeout 3000 Here's my app's code for listening the