UNPKG

5.58 kBMarkdownView Raw
1Go Go Go
2========
3
4Gogogo is a simple command-line tool designed to let you deploy web applications as easily as possible. It puts files into place on any server with upstart and gets it all configured.
5
6### Goals
7
81. Easy to setup
92. Easy to redeploy
103. Deploy to multiple servers
114. Deploy different branches to the same server
12
13Installation
14------------
15
16 npm -g install gogogo
17
18Change Log
19----------
20
21* 0.4.3 - added support for local deploys, and sudo for non-root users (see note below)
22* 0.4.0 - Added support for tracking support history, plugins, and a chef plugin
23* 0.3.3 - multi cron support, plus per-layer config
24* 0.3.0 - custom config file, cron support
25* 0.2.6 - git push force
26* 0.2.5 - Server Environment variables are preserved! Deploy monitors the log for a couple seconds.
27* 0.2.0 - gogogo list, logs, start, stop, restart, deploy
28
29Server Requirements
30-------------------
31
321. Upstart (included with ubuntu)
332. SSH Access
343. Git installed on both local computer and server
354. for non-root users, sudo must work without a password
36
37Usage
38-----
39
40In your local repo
41
421. `gogogo init`
43
442. edit ggg.js:
45
46``` JavaScript
47module.exports = {
48
49 // services
50 start: "node app.js",
51
52 // install
53 install: "npm install",
54
55 // cron jobs (from your app folder)
56 cron: {
57 someTask: { time: "0 3 * * *", command: "node sometask.js"},
58 }
59
60 // servers to deploy to
61 servers: {
62 dev: "deploy@dev.mycompany.com",
63 staging: ["deploy@staging.mycompany.com", "deploy@staging2.mycompany.com"]
64 prod: {
65 hosts: ["deploy@mycompany.com", "deploy@backup.mycompany.com"],
66 cron: {
67 someTask: {time: "0 3 * * *", command: "node sometask.js"},
68 anotherTask: {time: "0 3 * * *", command: "node secondTask.js"}
69 },
70 start: "prodstart app.js"
71 }
72 }
73}
74```
75
763. gogogo deploy dev master
77
78### Redeploy
79
80 # change some stuff and commit
81 ...
82
83 # deploy again
84 gogogo deploy test master
85
86### Plugins
87
88As of 0.4.0, gogogo supports plugins to help your deploys be more dynamic.
89
90gogogo plugins override a single deploy parameter (such as hosts) and are a simple
91file that exports a single function with the following signature:
92
93``` JavaScript
94module.exports = function(opts, cb) {
95...
96 cb(err, overrides)
97}
98```
99where opts is a hash of user definied options
100
101
102Currently, there is one bundled plugin, chefHosts, which integrates with opscode's knife to
103retrieve a list of servers to deploy too. Example of using a plugin is show below
104
105``` JavaScript
106...
107plugins: {
108 "chefHosts" : {
109 overrides: "hosts", // required field! defines the property to override
110 opts: {
111 role: "myapp",
112 env: "production"
113 }
114 },
115 "./plugins/myPlugin" { // user plugins are supported, relative to cwd
116 overrides: "install"
117 }
118},
119...
120```
121
122
123Limitations
124-----------
125
1261. Only works on ubuntu (requires upstart to be installed)
1272. You must change the port in either the code or an environment variable to run the same app twice on the same server
128
129Roadmap
130-------
131
132* gogogo rm
133* gogogo ps
134* ability to specify sub-folders that contain package.json files
135
136Help
137----
138
139### Actions
140
141 gogogo help
142 gogogo init - creates a ggg.js config file for you
143 gogogo deploy <name> <branch> — deploys branch to named server
144 gogogo restart <name>
145 gogogo start <name>
146 gogogo stop <name>
147 gogogo logs <name> — tail remote log
148 gogogo list — show available names
149 gogogo history <name> - shows a history of deployed commits
150
151
152 gogogo has an alias of ggg for saving you those precious keystrokes
153
154### Cron Support
155
156Gogogo currently supports a single cron action.
157
158``` JavaScript
159 module.exports = {
160 cron: {
161 cronName: {time: "0 3 * * *" command: " node something.js"}
162 }
163 ...
164 }
165```
166
167It will create a script in /etc/cron.d/, set the permissions correctly, and redirect log output to `cron.txt`
168
169### Environment variables
170
171If they are the same no matter which server is deployed, put them in your start script.
172
173 "start":"DB_HOST=localhost node app.js"
174
175If they refer to something about the server you are on, put them in /etc/environment.
176
177 # /etc/environment
178 NODE_ENV="production"
179
180### Multiple servers
181
182To deploy to multiple servers, just add multiple servers to the config file
183
184``` JavaScript
185 // ggg.js
186 module.exports = {
187 servers: {
188 dev: "deploy@dev.mycompany.com",
189 staging: "deploy@staging.mycompany.com"
190 }
191 }
192```
193
194Then deploy to them separately
195
196 gogogo deploy dev master
197 gogogo deploy staging master
198
199### Multiple branches on the same server
200
201You can deploy any branch over your old remote by pushing to it. To have multiple versions of an app running at the same time, call `gogogo create` with different names and the same server.
202
203``` JavaScript
204 // ggg.js
205 module.exports = {
206 servers: {
207 dev: "deploy@dev.mycompany.com",
208 featurex: "deploy@dev.mycompany.com"
209 }
210 }
211```
212
213Then deploy to them separately
214
215 gogogo deploy dev master
216 gogogo deploy featurex featurex
217
218Note that for web servers you'll want to change the port in your featurex branch or it will conflict.
219
220### Reinstall / Upgrade
221
222To reinstall, run `npm install -g gogogo` again, then redo the create step in your repository.
223
224### Gitignore
225
226Commit ggg.js to your repo, so anyone using the repo can deploy as long as they have ssh access to the server.
227
228### IMPORTANT NOTES!
229
230SSH is run with host key checking disabled! Its up to you to verify the authenticity of your hosts!
231
232