PM2 + Meteor无法正常工作

问题描述 投票:3回答:4

尝试运行时出错:

~/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
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 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
投票

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

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

在.meteor / local / build中


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!

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


0
投票

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

"interpreter"  : "bash"

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

© www.soinside.com 2019 - 2024. All rights reserved.