PM2结合nvm实现多项目node版本部署

nvm安装 略
pm2安装 略

执行pm2 ecosystem,生成ecosystem.config.js

module.exports = {  
    /**
     * Application configuration section
     * http://pm2.keymetrics.io/docs/usage/application-declaration/
     */
    apps: [

        // First application
        {
            name: 'app1',
            script: './app1/index.js',
            interpreter: "node@0.10.24",//也可以写为nvm的node路径,ex:~/.nvm/versions/v0.10.24/node
            env:{
                "NODE_ENV": "production"
            },
            env_production: {
                NODE_ENV: 'production'
            }
        },

        // Second application
        {
            name: 'app2',
            script: './app2/app.js',
            interpreter: "node@8.12.0",
            env: {
                COMMON_VARIABLE: 'true'
            },
            env_production: {
                NODE_ENV: 'production'
            }
        }
    ],

pm2 start eocsystem.config.js