javascript - 设置 pm2 以监控流星应用程序的步骤
问题描述
我正在尝试使用 pm2 来监控我的流星应用程序,旨在解决 cpu 100% 使用率的问题。
我参考了PM2 + Meteor Environment Setup,但结果看起来像失败了。
我的想法是流星过程根本没有启动。欢迎任何想法。
顺便说一句,我试过pm2-meteor,但可能是因为没有维护,现在无法成功运行。
我的代码结构是这样列出的,
+- cloud
+- package.json
+- client
+- server
+- pm2.json
+- private
+- public
+- server
在正常模式下,我通过获取云文件夹和“流星”指令来运行网络应用程序。
解决方案
我发现我的问题的原因是Nodejs 总是安装 4.2.6
所以在我的机器上更新了nodejs之后,我需要决定选择一种运行pm2的方式
1. pm2-meteor in https://github.com/andruschka/pm2-meteor
2. run mongodb and it listens to 172.0.0.1:27010
+ meteor build the app to be .tar.gz
+ pm2 run meteor app
我使用 2. 所以步骤是,
1. install mongodb, pm2, nodejs(nodejs installation with nvm please)
2. In order to create a mongodb service
- launch mongod by
mongod -dbpath=$(some_accessible_path) -logpath=$(some_accessible_path) --fork --replSet meteor
3. run mongo and get to mongo shell and key in commands bellow
a. var config = {_id:"meteor",members:[{_id:0,host:"127.0.0.1:27017"}]}
b. rs.initiate(config)
if the return value is {"ok":1}, mongodb service is ready.
4. pack meteor app
a. mkdir ~/cloud_build
b. get to the source code folder and use the command
meteor build --architecture=os.linux.x86_64 ~/cloud_build
c. cd ~/cloud_build
d. tar xvf some.tar.gz
e. you will get a bundle folder
f. cd that_bundle_folder/program/server && npm install
5. run pm2
a. create a file of pm2.json in the bundle folder
b. pm2 start pm2.json
pm2.json 看起来像下面的东西
{
"apps": [{
"name": "appName",
"cwd": "/yourhome/cloud_build/bundle",
"script": "main.js",
"env": {
"NODE_ENV": "production",
"WORKER_ID": "0",
"PORT": "3000",
"ROOT_URL": "http://yourweburl",
"MONGO_URL": "mongodb://localhost:27017/meteor",
"MONGO_OPLOG_URL": "mongodb://localhost:27017/local",
"HTTP_FORWARDED_COUNT": "1",
"METEOR_SETTINGS": {}
}
}]
}
推荐阅读
- linux - 为什么 musl ldconfig 忽略标准目录?
- java - java 8 路径过滤文件名
- scalability - 在虚拟化环境中测量时间
- java - StringBuilder 在Java中追加for循环
- jquery - toggleClass 不会删除“显示”类
- android - Android Studio Single Activity 充当多个
- haskell - 将函数应用于树结构时可以匹配期望类型
- vue.js - Vue:为什么这个计算属性不是响应式的?
- stanford-nlp - 多线程(无法访问像 ann 这样的全局变量)
- php - 在模板中使用的变量/代码,以便页面内容在现场显示