Javascript 设置pm2以监视meteor应用程序的步骤
我正在尝试使用pm2来监控我的meteor应用程序,打算解决cpu 100%使用率的问题 我做了裁判,但结果看起来像是失败了 我的想法是,流星过程根本就没有启动。欢迎提出任何意见 顺便说一下,我试过pm2 meteor,但可能是因为它没有维护,所以现在无法成功运行 我的代码结构如下所示Javascript 设置pm2以监视meteor应用程序的步骤,javascript,meteor,cpu-usage,pm2,Javascript,Meteor,Cpu Usage,Pm2,我正在尝试使用pm2来监控我的meteor应用程序,打算解决cpu 100%使用率的问题 我做了裁判,但结果看起来像是失败了 我的想法是,流星过程根本就没有启动。欢迎提出任何意见 顺便说一下,我试过pm2 meteor,但可能是因为它没有维护,所以现在无法成功运行 我的代码结构如下所示 +- cloud +- package.json +- client +- server +- pm2.json +- private +- public +- server 在
+- cloud
+- package.json
+- client
+- server
+- pm2.json
+- private
+- public
+- server
在正常模式下,我通过get to cloud文件夹和“meteor”指令运行web应用程序。我发现问题的原因在 因此,在我的机器上更新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": {}
}
}]
}
然后可以在中访问webapp。您需要在本地计算机上而不是服务器上初始化pm2 meteor。它使用配置文件为您构建和部署所有内容。见: