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

Commit 4357b50

Browse files
Nishad BakshiNishad Bakshi
authored andcommitted
Updated readmes
1 parent 922d1e6 commit 4357b50

File tree

2 files changed

+81
-3
lines changed

2 files changed

+81
-3
lines changed

app/templates/INSTALL.mdown

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Deploying to a server
1+
# Deploying to a server
22

33
To deploy, make sure both your local machine and your remote server/deployment target have pm2 installed with:
44

@@ -8,6 +8,8 @@ Make sure you have the file `ecosystem.json` with any saved deployment targets i
88

99
`gulp add-deploy-target`
1010

11+
**Note:** This command may not work on older projects! If it's not available you will need to modify the `ecosystem.json` file manually.
12+
1113
`ecosystem.json` will include any config as well as any deployment config along with your credentials. If you need to put in any credentials or sensitive information that can't be in the repository then answer the final question from `gulp add-deploy-target` with a yes and it will put the deployment config into `local.ecosystem.json`.
1214

1315
Once you've got your TARGETNAME (answer to the first question in `gulp add-deploy-target`) you can initialize the target host with:
@@ -50,7 +52,27 @@ Running `pm2 save` whenever you deploy a new app is very important as in the eve
5052

5153
Now that the app is started you will not have to stop or restart it when making updates. pm2 will automatically restart the app if any of it's files are changed so you can do `pm2 deploy TARGETNAME --force` from your local machine and the pm2 will automatically restart the app with any changes!
5254

53-
#Administration
55+
## Initializing httpd
56+
57+
Next to this, you likely want to enable the httpd daemon. Often only very limited ports are exposed on servers, and we usually deliberately configure the application outside that scope. Add a forwarding rule for the appropriate dns:
58+
59+
- sudo chkconfig --levels 2345 httpd on
60+
- sudo service httpd stop
61+
- sudo vi /etc/httpd/conf/httpd.conf, uncomment the line with:
62+
63+
NameVirtualHost *:80
64+
65+
- and append:
66+
67+
<VirtualHost *:80>
68+
ServerName @sample-app-name.demoserver.com
69+
RewriteEngine On
70+
RewriteRule ^(.*)$ http://localhost:@node-port$1 [P]
71+
</VirtualHost>
72+
73+
- sudo service httpd start
74+
75+
## Administration
5476

5577
To view all running pm2 applications use:
5678

@@ -80,3 +102,59 @@ For more information use the help commands or consult the documentation [here](h
80102

81103
`pm2 deploy help`
82104

105+
## Converting an existing project
106+
107+
If you've previously deployed an application using linux server scripts then you will need to remove the scripts and the old deployment.
108+
109+
To minimize application downtime, you should configure and deploy the project using pm2 before removing the old deployment.
110+
111+
When converting a project to pm2 you should create an `ecosystem.json` file with your desired deployment config and commit it into the project, follow the above instructions and deploy it to your target server. pm2 will deploy the project to `/space/projects/{appname}/source`. **Don't** run `pm2 startOrRestart ecosystem.json` yet though!
112+
113+
Now once you've almost finished deploying with pm2 you will need to stop it with the service scripts:
114+
115+
`service stop {appname}`
116+
117+
If you have a {appname}-watch script then stop that as well:
118+
119+
`service stop {appname}-watch`
120+
121+
You should now be able to run `pm2 startOrRestart ecosystem.json`
122+
123+
Now that the project is deployed and assuming it's running okay you will need to clean up the old deployment.
124+
125+
Firstly, remove the chkconfig
126+
127+
`chkconfig -del {appname}`
128+
129+
And also for the watch script if appropriate
130+
131+
`chkconfig -del {appname}-watch`
132+
133+
Then delete the scripts
134+
135+
`rm /etc/init.d/{appname}`
136+
137+
`rm /etc/{appname}`
138+
139+
And for the watch script:
140+
141+
`rm /etc/init.d/{appname}-watch`
142+
143+
Older projects were typically deployed using a .git .live folder structure, since we no longer need these you can delete them:
144+
145+
`rm -r /space/projects/{appname}.git`
146+
147+
`rm -r /space/projects/{appname}.live]`
148+
149+
Finally delete the git remote that pointed to the .git folder from your laptop:
150+
151+
cd to your project directory and run:
152+
153+
`git remote rm {DeploymentName}`
154+
155+
You can then finish off by deleting the old etc folder from the project folder as the scripts and documentation inside should no longer be needed:
156+
157+
`rm -r ./etc`
158+
159+
You should also copy THIS Install guide to your projects repository for the benefit of other users.
160+

app/templates/README.mdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Edit `./local.json` to set your desired ports
4848

4949
# Installation and deployment on server
5050

51-
See etc/INSTALL.md
51+
See INSTALL.md
5252

5353
# Data
5454

0 commit comments

Comments
 (0)