pm2

Node.js + Socket.io + Redis app via PM2 with large memory footprint

你。 提交于 2019-12-01 09:39:24
I'm new to both node.js and socket.io, but I'm trying to build a simple service that listens to Redis notifications (fed by PHP app), and broadcasts them to any users currently logged in, connected to a socket.io room e.g. 'site_name:user:user_id'. I have it working, but the memory footprint of the Node app quickly gets larger and larger, going from 100mb to 200+mb pretty quickly with about 100 users online and actively browsing, and I'm wondering if I have something set up wrong here. PM2 is handling the node app, and nginx is set up as reverse proxy. Server side: var app = require('express')

Node.js + Socket.io + Redis app via PM2 with large memory footprint

自古美人都是妖i 提交于 2019-12-01 09:32:40
问题 I'm new to both node.js and socket.io, but I'm trying to build a simple service that listens to Redis notifications (fed by PHP app), and broadcasts them to any users currently logged in, connected to a socket.io room e.g. 'site_name:user:user_id'. I have it working, but the memory footprint of the Node app quickly gets larger and larger, going from 100mb to 200+mb pretty quickly with about 100 users online and actively browsing, and I'm wondering if I have something set up wrong here. PM2 is

Why is PM2 not launching my Node process?

£可爱£侵袭症+ 提交于 2019-12-01 09:26:12
Previously I have had success implementing PM2, but not currently. My node app does run just fine if I start it manually, but nothing I do gets it to run via PM2, even though PM2 appears to be starting it up. Here's what I mean: If I run pm2 start server/index.js, the response in the terminal reads: $ pm2 start server/index.js [PM2] Spawning PM2 daemon with pm2_home=c:\pm2_system\.pm2 [PM2] PM2 Successfully daemonized [PM2] Starting D:\Program Files\nodeApps\service-management-api\server\index.js in fork_mode (1 instance) [PM2] Done.* Then the terminal prints out a table with App info. It

搭建临时邮箱

霸气de小男生 提交于 2019-12-01 06:56:01
今天来介绍一个临时搭建的即用即毁的邮箱系统 forsaken-mail 。当我们不想使用自己的真实邮箱,或者想批量注册账号的时候,就可以很方便的用上了 系统会自动分配随机邮箱,当有新邮件时页面会自动刷新,页面关闭后邮件即丢失,适合临时使用 源码 原作者 开源地址 。源码是nodejs编写。部署非常简单! Linux安装部署 服务器上需要事先安装 git 、 nodejs 等环境 安装步骤 从 github 上 clone 项目: git clone https://github.com/denghongcai/forsaken-mail.git 进入项目目录下,安装依赖 npm install 启动项目 npm start 这时通过 ip 地址+端口号 3000 就能访问页面了 开机自启 #安装pm2工具 npm install -g pm2 #启动项目 pm2 start bin/www #设置开机启动(可选) pm2 startup pm2 save Nginx域名转发 除了通过 IP 地址访问,还可以自定义邮箱域名 首先需要在域名解析中添加如下记录 添加域名: A 记录指向到服务器 ip 地址 添加域名: MX 记录指向到服务器 ip 地址,优先级设置10 这时使用 http://域名:3000/ 访问就可以看到页面了。但是带着端口访问,强迫症患者总是觉得不舒服

pm2简单介绍

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 05:14:49
非常简洁的一个使用记录,没有去做深究.先挖个坑. 介绍 pm2 和 forever 一样,都可以作为nodejs的守护程序,当然不仅仅是 nodejs .但相对比来说 pm2 的配置和图形化以及插件都做的不错. pm2 list : pm2 的控制台,这部分花钱才能使用大部分功能. 安装 1 npm install -g pm2 pm2使用 12345 cd staticpm2 start app.js --name "static" -e ~/logs/static_err.log -o logs/static_out.log --log-date-format "YYYY-MM-DD HH:mm Z"cd apipm2 start app.js --name "api" --log-date-format "YYYY-MM-DD HH:mm Z" -e logs/api_err.log -o ~/logs/api_out.log 配置文件的使用 上面那样写,太麻烦,可以使用配置方式 pm2 start pm2.json 12345678910111213 { "apps":[{ "name":"test_api", "cwd":"/root/code/test-api", "args":"--port=1550", "env":{ "NODE_ENV":"test" },

Use sudo inside Dockerfile (Alpine)

好久不见. 提交于 2019-12-01 04:11:19
问题 I have this Dockerfile ... FROM keymetrics/pm2:latest-alpine RUN apk update && \ apk upgrade && \ apk add \ bash COPY . ./ EXPOSE 1886 80 443 CMD pm2-docker start --auto-exit --env ${NODE_ENV} ecosystem.config.js How can I execute the CMD command using sudo ? I need to do this because the port 443 is allowed only for sudo user. 回答1: The su-exec can be used in alpine. Do add it the package, if not already available, add the following to your Dockerfile RUN apk add --no-cache su-exec Inside

How to add production mode to sailsjs app when started using PM2

青春壹個敷衍的年華 提交于 2019-12-01 04:03:23
问题 To start sailsjs in production mode you append --prod . Run: node app.js --prod I'm using PM2 and a simple json file for settings, which contains name of process and scriptname, to kick off the node process. How would I pass the production argument using PM2? 回答1: Read PM2 JSON app declaration. E.g. (not tested) [{ "name" : "Sails", "script" : "./app.js", "args" : "['--prod']" }] 回答2: first delete: pm2 delete app again: pm2 start app.js -x -- --prod 回答3: You can also use something like this:

How Can I run PM2 with Angular-Cli? - Angular2

泪湿孤枕 提交于 2019-12-01 03:36:57
How can I run: ng serve --prod with pm2? ng serve from angular-cli, Angular2. I'm running on DigitalOcean. I have tried to test with http-server -p 4200 -d false in the dist/ folder after ng build --prod When I request from the domain https://www.unibookkh.com/ , i got 404 error: (I've already setup nginx to listen to port 4200. I test with http-server because I think I maybe can run pm2 through this command pm2 start my_app_process.json where my_app_process.json { "apps": [ { "name": "angular", "cwd": "~/angular2", "args": "-p 4200 -d false", "script": "/usr/bin/http-server" } ] } Any better

pm2 Startup not starting up on Ubuntu

主宰稳场 提交于 2019-11-30 19:18:24
I am having difficulty getting pm2 to restart (itself and two node/express files, app.js & app2.js ) on a server re-boot. Below is the processes I have tried: pm2 startup pm2 start app.js pm2 start app2.js pm2 startup ubuntu (also tried systemd and with/without -u username) pm2 save I ran the above commands in every possible combination and nothing worked. I tried running as root and it did not work either. My ~/.pm2/dump.pm2 file contains information so I am not sure where else to look. I have attempted to modify my /etc/init.d/pm2-init.sh file according to this issue but it did not help. My

How to specify a port number for pm2

可紊 提交于 2019-11-30 06:06:26
I'm trying to use pm2 to manage a node.js cluster pm2 start . -i 3 I'm currently running the app on heroku and using a Procfile with the above command, but I cannot figure out how to configure pm2 to use the existing PORT env var. Something like pm2 start . -p $PORT What am I missing? You can use environment variable. For example: 1) NODE_PORT=3002 pm2 start -I 0 app.js 2) Read value in app: console.log(process.env.NODE_PORT); Or, if you are build express app: 1) PORT=3002 pm2 start -I 0 ./bin/www 2) Express load PORT automatically at start application. You need to use -- to tell pm2 to stop