Skip to content
This repository was archived by the owner on Oct 5, 2020. It is now read-only.

Commit 0487640

Browse files
author
Nishad Bakshi
committed
Updated readme, tidied js files and replaced previous gulp tasks with gulp add-deploy-target
1 parent 77142e1 commit 0487640

File tree

5 files changed

+266
-265
lines changed

5 files changed

+266
-265
lines changed

app/templates/README.mdown

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,29 +72,51 @@ XML, Binary, and Text data out of the box.
7272

7373
## Running with PM2
7474

75-
To run you must install pm2 with:
75+
To run you must first install pm2 if you do not have it with:
7676

7777
`npm install pm2 -g`
7878

79-
Make sure you have the file `process.json` if it's missing then run:
79+
It's very **Important** that when deploying to a secure server that you do all pm2 commands as the pm2 user by using:
8080

81-
`gulp init-process`
82-
83-
This file will also include any config your node layer needs eg. mlHost, mlPort, nodePort, mlPassword etc.
81+
`sudo su pm2`
8482

8583
You can then launch the app using pm2 with:
8684

87-
`pm2 startOrRestart process.json`
85+
`pm2 startOrRestart boot.json`
86+
87+
You can also launch the app using different environment configurations in boot.json (env name prefixed with "env_"), for example:
88+
89+
`pm2 startOrRestart boot.json --env prod`
90+
91+
You can also save your current pm2 deployments with:
8892

89-
You can also launch the app using different environment configuration (env name prefixed with "env_") using:
93+
`pm2 save`
9094

91-
`pm2 startOrRestart process.json --env build`
95+
You should run `pm2 save` whenever you deploy a new app.
9296

9397
To view all running pm2 applications use:
9498

9599
`pm2 list`
96100

97-
And for more information use:
101+
To view any logs use:
102+
103+
`pm2 logs`
104+
105+
To monitor ram or cpu usage use:
106+
107+
`pm2 monit`
108+
109+
**If** you've deployed applications previously but don't see them when you run pm2 list then it might be because you're not logged in as the pm2 user or you deployed them under a different user.
110+
111+
If you accidently launch pm2 under your own account then you can kill the process with:
112+
113+
`pm2 kill`
114+
115+
And if you accidently run that command when logged in as the pm2 user then you can start pm2 and resurrect all processes from the last `pm2 save` with:
116+
117+
`pm2 resurrect`
118+
119+
For more information use:
98120

99121
`pm2 help`
100122

@@ -104,32 +126,28 @@ To deploy, make sure both your local machine and your remote server/deployment t
104126

105127
`npm install pm2 -g`
106128

107-
Make sure you have the file `ecosystem.json` if it's missing then run:
129+
Make sure you have the file `ecosystem.json` with any saved deployment targets inside, to create this file or add a new deployment target run:
108130

109-
`gulp init-ecosystem`
131+
`gulp add-deploy-target`
110132

111-
`ecosystem.json` will include any config as well as any deployment config along with your credentials. It is git ignored by default and we recommend you avoid commiting it and instead put any repository appropriate configuration in `process.json`
112-
113-
Using the sample target in ecosystem.json as a guide, set up a target to deploy to. Your configuration must have an ssh key, remote server user, git repository potentially with credentials and a valid path that isn't being used.
133+
`ecosystem.json` will include any config as well as any deployment config along with your credentials. It is git ignored by default and we recommend you avoid commiting it and instead put any repository appropriate configuration in `boot.json`
114134

115135
First initialize the target host:
116136

117-
`pm2 deploy ecosystem.json TARGETNAME setup`
137+
`pm2 deploy TARGETNAME setup`
118138

119-
Then deploy new code with:
139+
Then deploy your latest code from your git repository and run any post-deploy commands with:
120140

121-
`pm2 deploy ecosystem.json TARGETNAME`
141+
`pm2 deploy TARGETNAME`
122142

123-
**Hint**, If you do not specify `ecosystem.json` pm2 automatically looks for it in your current directory
143+
**Hint**, pm2 automatically looks `ecosystem.json` in your current directory, but you can use other config files with `pm2 deploy otherEcosystemFile.json TARGETNAME`
124144

125-
If you want to deploy without commiting your current code use `--force`:
145+
If you have files you haven't commited, pm2 will ask you to commit them before deploying, to ignore this use `--force`:
126146

127147
`pm2 deploy TARGETNAME --force`
128148

129-
You can also run commands on the server with `exec` such as starting the app:
130-
131-
`pm2 deploy ecosystem.json TARGETNAME exec "pm2 startOrRestart process.json"`
149+
With your application deployed follow the above "Running with PM2" instructions to start the application, once you've started the app it will listen for changes and automatically restart when you make deploy changes with `pm2 deploy TARGETNAME`.
132150

133151
For more information use:
134152

135-
`pm2 deploy help`
153+
`pm2 deploy help`

app/templates/boot.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"apps": [{
3+
"name": "@sample-app-name",
4+
"script": "./node-server/node-app.js",
5+
"watch": true,
6+
"env": {
7+
"NODE_ENV": "local"
8+
},
9+
"env_local": {
10+
"NODE_ENV": "local"
11+
},
12+
"env_dev": {
13+
"NODE_ENV": "dev"
14+
},
15+
"env_prod": {
16+
"NODE_ENV": "prod"
17+
}
18+
}]
19+
}

0 commit comments

Comments
 (0)