【问题标题】:PM2 + Meteor not workingPM2 + Meteor 不工作
【发布时间】:2017-12-16 19:43:48
【问题描述】:

尝试运行时出现错误:

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

【问题讨论】:

    标签: meteor pm2


    【解决方案1】:

    我相信这个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 服务器的配置中阻止该端口)。

    【讨论】:

      【解决方案2】:

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

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

      在 .meteor/local/build 中

      【讨论】:

        【解决方案3】:

        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)中使用流星

        【讨论】:

        • 将 json 文件更改为“脚本”:“/home/josh/.meteor/meteor”失败并出现以下错误:/home/josh/.meteor/tools/c2a0453c51/bin/meteor:3 BUNDLE_VERSION=0.3.33 ^^^。我找到了这个解决方法,但它没有使用 json 文件或 bash 脚本:pm2 start ~/.meteor/meteor -x --interpreter bash
        【解决方案4】:

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

        "interpreter"  : "bash"
        

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

        【讨论】:

          猜你喜欢
          • 2018-05-04
          • 2015-12-26
          • 2016-06-05
          • 2017-12-04
          • 2015-03-09
          • 1970-01-01
          • 1970-01-01
          • 2018-02-05
          • 1970-01-01
          相关资源
          最近更新 更多