尝试运行时出错:
~/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:
{
"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"
}
我也试试这个: 猫开始
#!/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脚本时:
#!/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脚本,该脚本不允许使用导出?
答案 0 :(得分:2)
我相信这种process.json
语法更正确:
{
"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
启动它:
#!/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那么几乎任何人都可以通过http://myapp.example.com:3000访问它加密层周围,除非您在Web服务器的配置中阻止该端口。)
答案 1 :(得分:1)
这就是我的流星应用程序(望远镜)工作的方式
ROOT_URL=http://localhost:3000 PORT=3000 MONGO_URL=mongodb://127.0.0.1:27017/Telescope pm2 start main.js
在.meteor / local / build
中答案 2 :(得分:0)
Meteor实际上并没有从/ usr / local / bin / meteor运行,该脚本仅用于引导等,完成后重定向到〜/ .meteor / meteor
来自/ usr / local / bin / meteor:
# All this script does is exec ~/.meteor/meteor. But what if you don't have it
# yet? In that case, it downloads a "bootstrap tarball", which contains the
# latest version of the Meteor tools, and plops it down at ~/.meteor. In fact,
# once you've run this once, you don't even really need this script: you can put
# ~/.meteor/ into your PATH, or a symlink to ~/.meteor/meteor into some other
# PATH directory. No special permissions needed!
所以你需要做的是改变你的脚本指针,使用你的"仓库目录" (〜/流星/流星)
答案 3 :(得分:0)
这意味着pm2需要一些语法并在启动脚本中找到另一个语法。为了将其指向正确的语法,请将其添加到config.json
文件中:
"interpreter" : "bash"
P.S。:在命令行中添加此参数不起作用