【问题标题】:How to deploy Parse Server with Express, Nginx and pm2如何使用 Express、Nginx 和 pm2 部署 Parse Server
【发布时间】:2020-01-11 07:25:47
【问题描述】:

我已经成功地使用 pm2、MongoDB 和 Nginx 部署了解析服务器,并且我可以从本地主机外部从它进行 POST 和 GET。我在 DigitalOcean 上做这个,我用这个 page 作为参考。我现在想将 ExpressJS 添加到 parse 的 npm 全局安装中,但我不知道该怎么做。根据 Parse 教程 parse-server-example,我通过手动使用“npm start”让 Parse+ExpressJS 工作。如何将它包含在全局安装中,以便在 pm2 开始解析时包含它?

这是我的生态系统.json,如果有用的话。

{                                      
    "apps" : [{
      "name"        : "parse-wrapper",
      "script"      : "/usr/local/bin/parse-server",
      "watch"       : true,
      "merge_logs"  : true,               
      "cwd"         : "/home/parse",       
      "env": {                             
        "PARSE_SERVER_CLOUD_CODE_MAIN": "/home/parse/cloud/main.js",
        "PARSE_SERVER_DATABASE_URI": "mongodb://<user>:<password>@127.0.0.1:27017/dev",                        
        "PARSE_SERVER_APPLICATION_ID": "<myAppId>",
        "PARSE_SERVER_MASTER_KEY": "myMasterKey",
      }                                 
    }]                                   
}

我使用的pm2命令序列是:

pm2 start ecosystem.json
pm2 save
sudo pm2 startup ubuntu -u parse --hp /home/parse/

提前感谢您的帮助。

【问题讨论】:

    标签: express parse-platform pm2


    【解决方案1】:

    基于您的 ref repo express 已经使用 package.json 与 Parse 一起安装 你可以在index.js中使用express方法

    不需要像package.json文件中提到的那样将express安装为全局

    要开始使用 pm2,您可以提及以下脚本参数

    script: "npm run start"
    

    将生态系统.json 移动到您的项目根文件夹中并在您的项目文件夹中运行 pm2 start 命令。

    【讨论】:

    • 感谢您的回复。为了清楚起见,我下载了 parse-server-example repo,并执行以下命令: ` cd ; pm2 npm 运行开始; pm2 保存; sudo pm2 启动 ubuntu -u parse --hp /home/parse/` 谢谢。
    【解决方案2】:

    我想通了,这是我用来配置 pm2 的命令序列。

    <login as the parse user, or su -l parse>
    git clone https://github.com/ppk007/parse-server-example ~/git/parse-server-dev
    cd ~/get/parse-server-dev
    npm install
    <change the config files - I edited index.js>
    pm2 start index.js
    pm2 save
    exit # exit the parse user shell and go to the normal user shell
    sudo pm2 startup ubuntu -u parse --hp /home/parse/
    

    【讨论】:

      猜你喜欢
      • 2020-08-17
      • 1970-01-01
      • 1970-01-01
      • 2015-08-14
      • 1970-01-01
      • 2018-12-28
      • 1970-01-01
      • 2021-07-29
      • 2022-01-06
      相关资源
      最近更新 更多