Ubuntu的常用命令(五)发布程序

release (pm2)

pm2

1
pm2 start [app]

list all

1
pm2 list

[app] details

1
pm2 show [app]

ecosystem.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
"apps" : [{
"name" : "blog",
"script" : "app.js",
"env": {
"COMMON_VARIABLE": "true"
},
"env_production" : {
"NODE_ENV": "production"
}
}],
"deploy" : {
"production" : {
"user" : "copy",
"host" : ["192.168.1.98"],
"port" : "22",
"ref" : "origin/master",
"repo" : "git@github.com:co-py/blog-api.git",
"path" : "/var/www/blog/production",
"ssh_options": "StrictHostKeyChecking=no",
"pre-deploy-local" : "echo 'This is a local executed command'",
"post-deploy" : "npm install --registry=https://registry.npm.taobao.org && pm2 startOrRestart ecosystem.json --env production",
"env" : {
"NODE_ENV": "production"
}
}
}
}

deploy

1
2
# pm2 deploy <configuration_file> <environment> setup
pm2 deploy ecosystem.json production setup