美文网首页Node
pm2 部署 node.js项目踩过的坑

pm2 部署 node.js项目踩过的坑

作者: Xinxing_Li | 来源:发表于2018-08-09 20:12 被阅读0次

    pm2部署指令

    pm2 deploy ecosystem.json production setup
    pm2 deploy ecosystem.json production
    

    配置文件:

    //ecosystem.json
    {
        "apps": [{
            "name": "Ice",
            "script": "server.js",
            "env": {
                "COMMON_VARIABLE": "true"
            },
            "env_production": {
                "NODE_ENV": "production"
            }
    
        }],
        "deploy": {
            "production": {
                "user": "root",
                "host": ["120.79.3.xxx"],
                //"port": "39999",
                "ref": "origin/master",
                "repo": "git@code.aliyun.com:lxx2013/ice.git",
                "path": "/home/www/ice/production",
                "ssh_options": "StrictHostKeyChecking=no",
                "pre-deploy-local": "echo 'Deploy Done!'",
                "env": {
                    "NODE_ENV": "production"
                }
            }
        }
    }
    

    CentOS7 pm2 部署node错误提示pm2: command not found]

    lxx@imac:~/Desktop/nodejs/ice$ pm2 deploy ecosystem.json production
    --> Deploying to production environment
    --> on host 120.79.3.108
      ○ deploying origin/master
      ○ executing pre-deploy-local
    Deploy Done!
      ○ hook pre-deploy
      ○ fetching updates
      ○ full fetch
    正在获取 origin
      ○ resetting HEAD to origin/master
    HEAD 现在位于 e286cc6 =>aliyun
      ○ executing post-deploy `export NODE_ENV=production && pm2 startOrRestart ecosystem.json --env production`
    bash: pm2: 未找到命令
    
      post-deploy hook failed
    
    Deploy failed
    1
    

    解决方法:

    whereis pm2
    pm2: /opt/nodejs/bin/pm2
    
    sudo ln -s /opt/nodejs/bin/pm2 /usr/bin/pm2
    

    nginx http重定向https正确写法

    server {
        listen      80;
        server_name    my.domain.com;
        return      301 https://$server_name$request_uri;
    }
    
    server {
        listen      443 ssl;
        server_name    my.domain.com;
    
        [....]
    }
    

    相关文章

      网友评论

        本文标题:pm2 部署 node.js项目踩过的坑

        本文链接:https://www.haomeiwen.com/subject/upncbftx.html