1、
2、新建ecosystem.json
{ "app": [{ "name" :"Ice", "script": "service.js", "env" :{ "COMMON_VARIABLE": "true" }, "env_production": { "NODE_ENV": "production" } }], "deploy": { "production": { "user": "brad", "host": ["xxx.78.174.xxx"], "ref": "origin/master", "port": "3006", "repo": "[email protected]:dt_xz/ice.git", "path": "/home/brad/ice/production", "ssh_options": "StrictHostKeyChecking=no", "pre-deploy-local": "echo ‘Deploy Done‘", "env": { "NODE_ENV": "production" } } } }
3、提交代码,在本地运行命令:
pm2 deploy ecosystem.json production setup