PM2 +流星不起作用 [英] PM2 + Meteor not working
问题描述
尝试运行它时出现错误:
I get an error when trying to run it:
~/projects/test-app
/usr/local/bin/meteor:3
# This is the script that we install somewhere in your $PATH (as "meteor")
这是我运行的命令:
pm2 start meteor-pm2.json
这是meteor-pm2.json:
And here is meteor-pm2.json:
{
"name" : "test-app",
"script" : "/usr/local/bin/meteor",
"MAIL_URL":"smtp://yourmail_configuration_here",
"MONGO_URL":"mongodb://localhost:27017/meteor",
"ROOT_URL":"https://www.mysite.com/",
"PORT":"3000",
"out_file":"/home/josh/logs/app.log",
"error_file":"/home/josh/logs/err.log"
}
我也尝试这样做: 猫开始
I also try this: cat start
#!/bin/bash
MONGO_URL="mongodb://localhost:27017/meteor"
PORT=3000
ROOT_URL="https://www.mysite.com/"
/usr/local/bin/meteor
然后运行:
pm2 start ./start -x interpreter bash
我得到:
/usr/local/bin/meteor
^
ReferenceError: usr is not defined
当我通过添加导出来修改bash脚本时:
when i modify the bash script by adding the export:
#!/bin/bash
export MONGO_URL="mongodb://localhost:27017/meteor"
export PORT=3000
export ROOT_URL="https://www.mysite.com/"
/usr/local/bin/meteor
我得到:
export - SyntaxError: Unexpected reserved word
任何想法我在做什么错? pm2是否尝试在其自己的特殊脚本解释器中运行bash脚本,该解释器不允许使用export?
Any ideas what am I doing wrong? Is pm2 trying to run the bash script in it's own special script interpreter that doesn't allow the use of export?
推荐答案
我相信这种process.json
语法更正确:
I believe this process.json
syntax is more correct:
{
"apps": [
{
"name": "myAppName",
"script": "./bundle/main.js",
"log_date_format": "YYYY-MM-DD",
"exec_mode": "fork_mode",
"env": {
"PORT": 3000,
"MONGO_URL": "mongodb://127.0.0.1/meteor",
"ROOT_URL": "https://myapp.example.com/",
"BIND_IP": "127.0.0.1"
}
}
]
}
然后我使用包含以下内容的run.sh
来启动它:
then I just start it using run.sh
which contains:
#!/bin/sh
#
# This shell script starts the actual
# app in the production environtment.
#
pm2 start process.json -i max # Enable load-balancer and cluster features
注意:BIND_IP env var可以将其从默认值(0.0.0.0)更改. 0.0.0.0将使该应用可以在ssl代理层周围访问(如果您将SSL/TLS与nginx或其他Web服务器一起使用,并且BIND_IP设置为0.0.0.0,那么几乎任何人都可以通过
Note: the BIND_IP env var is there to change it from the default (0.0.0.0). The 0.0.0.0 would make the app accessible around the ssl proxy layer (if you use SSL/TLS with nginx or some other web server and the BIND_IP is set to 0.0.0.0 then pretty much anyone could access it via http://myapp.example.com:3000 around the encrypted layer, unless you block that port in your web server's configuration).
这篇关于PM2 +流星不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!