pm2

node 项目中 koa2 环境搭建 以及项目发布

别等时光非礼了梦想. 提交于 2019-11-28 07:00:31
环境搭建: 1、Koa 必须使用 7.6 以上的版本。如果你的版本低于这个要求,就要先升级 Node。 查看node版本方法:node -v 2、使用koa-generator生成器生成项目 安装koa-generator: npm install -g koa-generator   使用koa-generator生成koa2项目 koa2 HelloKoa2   成功创建项目后,进入项目目录,并执行 npm install 命令 cd HelloKoa2 npm install 3、启动项目: npm start 项目启动后,默认端口号是3000,在浏览器中运行可以得到下图效果,说明运行成功 发布: 1. 首先确保服务器环境支持:node、git 如果没有,请先安装node、git环境。两个安装时都默认next即可。 安装完成后,打开dos命令,查看node、npm、git 版本,命令分别是: node -v git -version npm -v 2. 确保安装后,安装npm2,命令如下: npm install pm2 -g 安装完成后,查看pm2的版本: pm2 -v 3. 为确保项目中使用到的node包都能正常下载,让我们先把npm 的镜像切换为淘宝镜像 npm config set registry http://registry.npm.taobao.org/

Can pm2 run an 'npm start' script

浪尽此生 提交于 2019-11-28 02:39:54
Is there a way for pm2 to run an npm start script or do you just have to run pm2 start app.js So in development npm start Then in production with pm2 you would run something like pm2 start 'npm start' There is an equivalent way to do this in forever forever start -c "npm start" ./ PM2 now supports npm start: pm2 start npm -- start Those who are using a configuration script like a .json file to run the pm2 process can use npm start or any other script like this - my-app-pm2.json { "apps": [ { "name": "my-app", "script": "npm", "args" : "start" } ] } Then simply - pm2 start my-app-pm2.json Edit

Express 4 + pm2 watch not working

依然范特西╮ 提交于 2019-11-27 18:01:45
I'm running pm2 with this: pm2 start bin/www --watch ../ Problem is that when I update app.js in the root folder, it doesn't seem to be autorestarting node. Any ideas? Figured out a solution: //processes.json: { "apps" : [{ "name" : "someExpress4App", "script" : "bin/www", "watch" : "../", "log_date_format" : "YYYY-MM-DD HH:mm Z", }] } Put that on the root of your project, then run your pm2 as so: pm2 start processes.json 来源: https://stackoverflow.com/questions/27882759/express-4-pm2-watch-not-working

How to pass arguments to app using pm2?

随声附和 提交于 2019-11-27 09:44:44
问题 I am using pm2 to start my app but i am not able to pass argument to it. the command I am using is pm2 start app.js -- dev. Though this works with forever. 回答1: You can do as stated in this ticket: https://github.com/Unitech/pm2/issues/13 Though if you're passing the environment you may want to consider leveraging environment variables. With this you create a variable which can be accessed by any process in that environment with process.env.* . So you have a configuration file config.json : {

Getting MIME type errors with MEAN stack project while deploying it

…衆ロ難τιáo~ 提交于 2019-11-27 07:27:19
问题 My question is strictly related to the deployment. My code is good. At first I asked this question, please read that question as well. I have given detailed info about the project there also. However, I got some good response and I followed these steps from the same: You have to use ng build --prod for compile your development file. Then you need to setup your node.js file. Then just upload all the server files and dist folder to server. And run the server using pm2 . And run just pm2 start

Express 4 + pm2 watch not working

China☆狼群 提交于 2019-11-27 04:14:37
问题 I'm running pm2 with this: pm2 start bin/www --watch ../ Problem is that when I update app.js in the root folder, it doesn't seem to be autorestarting node. Any ideas? 回答1: Figured out a solution: //processes.json: { "apps" : [{ "name" : "someExpress4App", "script" : "bin/www", "watch" : "../", "log_date_format" : "YYYY-MM-DD HH:mm Z", }] } Put that on the root of your project, then run your pm2 as so: pm2 start processes.json 来源: https://stackoverflow.com/questions/27882759/express-4-pm2

Node线上部署管理器PM2

╄→尐↘猪︶ㄣ 提交于 2019-11-27 02:43:33
PM2是一个带有负载均衡功能的Node应用的进程管理器。PM2可以利用服务器上的所有CPU,并保证进程永远都活着,0秒的重载,部署管理多个Node项目。PM2是Node线上部署完美的管理工具。 PM2安装 npm install -g pm2 PM2用法 $ pm2 start app.js -i 4 #后台运行pm2,启动4个app.js,也可以用’max’参数,进程数目依赖于Cpu的核心数目 $ pm2 start app.js –name my-api # 命名进程 $ pm2 restart 0 # 重启指定的进程 $ pm2 restart all # 重启所有进程 $ pm2 reload all # 0秒停机重载进程 (用于NETWORKED进程) $ pm2 stop 0 # 停止指定的进程 $ pm2 stop all # 停止所有进程 $ pm2 startup # 产生init脚本,保持进程活着 $ pm2 delete 0 # 杀死指定的进程 $ pm2 delete all # 杀死全部进程 $ pm2 web # 运行健壮的 computer API endpoint (http://localhost:9615) $ pm2 list # 列出由pm2管理的所有进程信息。 $ pm2 monit # 监视每个node进程的CPU和内存的使用情况。 $

mongoError: Topology was destroyed

≡放荡痞女 提交于 2019-11-26 15:10:24
I have a REST service built in node.js with Restify and Mongoose and a mongoDB with a collection with about 30.000 regular sized documents. I have my node service running through pmx and pm2. Yesterday, suddenly, node started crapping out errors with the message "MongoError: Topology was destroyed", nothing more. I have no idea what is meant by this and what could have possibly triggered this. there is also not much to be found when google-searching this. So I thought I'd ask here. After restarting the node service today, the errors stopped coming in. I also have one of these running in

爬虫day6 js加密和混淆的解析

ⅰ亾dé卋堺 提交于 2019-11-26 13:59:47
爬虫day6 关于< https://www.aqistudy.cn/html/city_detail.html 中国空气质量在线监测分析平台 js加密和混淆的解析 刚开始是的日期没有,加载,是因为已经加载完了,换一个日期. 可以看到数据是动态加载的 但是数据加密了 post请求,而且请求的数据也加密了 可能是谷歌浏览器的js没有监听,所以换比较好用的火狐浏览器 事件监听 getData请求数据 找到element(谷歌浏览器)(定义处) 可以看到执行了getAQI和getweather function getWeatherData() { var method = 'GETCITYWEATHER'; var param = {}; param.city = city; param.type = type; param.startTime = startTime; param.endTime = endTime; getServerData(method, param, function(obj) { data = obj.data; if(data.total>0) { dataTemp.splice(0, dataTemp.length); dataHumi.splice(0, dataHumi.length); dataWind.splice(0, dataWind