3

尝试运行它时出现错误:

~/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"
}

我也试试这个: 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 脚本时:

#!/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 脚本?

4

4 回答 4

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 环境变量用于将其从默认值 (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 服务器的配置中阻止该端口)。

于 2015-03-25T17:52:28.007 回答
1

这就是我让我的流星应用程序(望远镜)工作的方式

 ROOT_URL=http://localhost:3000 PORT=3000 MONGO_URL=mongodb://127.0.0.1:27017/Telescope pm2 start main.js

在 .meteor/local/build 里面

于 2015-03-02T04:51:24.430 回答
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!

所以你需要做的是改变你的脚本指针在你的“仓库目录”(~/meteor/meteor)中使用meteor

于 2014-04-21T08:39:51.460 回答
0

这意味着 pm2 需要一些语法并在启动脚本中找到另一个。为了将其定向到正确的语法,请将其添加到您的config.json文件中:

"interpreter"  : "bash"

PS:在命令行中添加这个参数不起作用

于 2017-12-16T11:43:48.023 回答