UNPKG

7.34 kBMarkdownView Raw
1Go Go Go
2========
3
4Gogogo is a simple command-line tool for easily deploying command-line
5applications. It puts files into place on any server with upstart and gets it
6all configured.
7
8### Goals
9
101. Easy to setup
112. Easy to redeploy
123. Deploy to multiple servers
134. Deploy different branches to the same server
14
15Installation
16------------
17
18 npm -g install gogogo
19
20Change Log
21----------
22
23* 0.5.0 - Add ability to support running multiple processes in one deploy
24 target
25* 0.4.10 - Add a command to run a command on the server, plus colorized output
26* 0.4.8 - automatically add logrotate files, make upstart work properly on
27 reboot
28* 0.4.3 - added support for local deploys, and sudo for non-root users (see
29 note below)
30* 0.4.0 - Added support for tracking support history, plugins, and a chef
31 plugin
32* 0.3.3 - multi cron support, plus per-layer config
33* 0.3.0 - custom config file, cron support
34* 0.2.6 - git push force
35* 0.2.5 - Server Environment variables are preserved! Deploy monitors the log
36 for a couple seconds.
37* 0.2.0 - gogogo list, logs, start, stop, restart, deploy
38
39Server Requirements
40-------------------
41
421. Upstart (included with ubuntu)
432. SSH Access
443. Git installed on both local computer and server
454. for non-root users, sudo must work without a password
46
47Usage
48-----
49
50In your local repo
51
521. `ggg init`
53
542. edit ggg.js:
55
56``` JavaScript
57module.exports = {
58 // services
59 // can either be a string or an object with mutiple processes to start up
60 start: "node app.js",
61 /* or
62 start: {
63 web: 'node app.js',
64 worker 'node worker.js',
65 montior: 'node monitor.js'
66 },
67 */
68
69 // install
70 install: "npm install",
71
72 // cron jobs (from your app folder)
73 cron: {
74 someTask: { time: "0 3 * * *", command: "node sometask.js"},
75 },
76
77 // targets to deploy to
78 servers: {
79 dev: "deploy@dev.mycompany.com",
80 staging: ["deploy@staging.mycompany.com", "deploy@staging2.mycompany.com"],
81 prod: {
82 hosts: ["deploy@mycompany.com", "deploy@backup.mycompany.com"],
83 cron: {
84 someTask: {time: "0 3 * * *", command: "node sometask.js"},
85 anotherTask: {time: "0 3 * * *", command: "node secondTask.js"}
86 },
87 start: "prodstart app.js"
88 }
89 }
90}
91```
92
933. ggg deploy dev master
94
95### Redeploy
96
97 # change some stuff and commit
98 ...
99
100 # deploy again
101 ggg deploy test master
102
103
104Limitations
105-----------
106
1071. Only works on ubuntu (requires upstart to be installed)
1082. You must change the port in either the code or an environment variable to
109 run the same app twice on the same server
110
111Roadmap
112-------
113
114* Clean up cron files when removing a cronjob after a deploy
115
116Help
117----
118
119### Actions
120
121```bash
122ggg help
123ggg init - creates a ggg.js config file for you
124ggg deploy <target> <branch> — deploys branch to named server
125ggg restart <target:process>
126ggg start <target:process>
127ggg stop <target:process>
128ggg logs <target:process> — tail remote log
129ggg list — show available names
130ggg history <target> - shows a history of deployed commits
131ggg command <target> <command> - run a command on the server in base directory
132```
133
134gogogo is aliased to ggg for SWEET EFFICIENCY
135
136### Cron Support
137
138gogogo can create cron jobs for you on deploy.
139
140``` JavaScript
141module.exports = {
142 cron: {
143 cronName: {time: "0 3 * * *" command: " node something.js"}
144 }
145}
146```
147
148It will create a script in /etc/cron.d/, set the permissions correctly, and
149redirect log output to `cron_cronName.log`.
150
151You can have multiple cron commands by having multiple keys in the cron object:
152
153```JavaScript
154module.exports = {
155 cron: {
156 cronName: {time: "0 3 * * *" command: "node something.js"},
157 anotherCron: {time: "0 1 * * *" command: "node somethingElse.js"}
158 }
159}
160```
161
162gogogo isn't smart enough yet to remove old cron files it created when you
163change or remove cronjobs, so you'll have to do that yourself now.
164
165### Multiple processes under one deploy target
166
167gogogo supports running multiple processes under one deploy target. Let's look
168at an example.
169
170If the value of the `start` property is a string, your target will only have
171one process. You can start, stop, restart and log it by running
172`ggg <start|stop|logs|restart> <target>`.
173
174
175```JavaScript
176module.exports = {
177 start: 'echo "foo"'
178}
179```
180
181If the value of the `start` property is an object, your target will have
182multiple processes associated with it. Check out an example ggg.js file.
183
184```JavaScript
185module.exports = {
186 servers: {
187 prod: {
188 hosts: ["deploy@mycompany.com", "deploy@backup.mycompany.com"],
189 install: "npm install",
190 start: {
191 web: 'echo "starting web"',
192 worker: 'echo "starting worker"',
193 monitor: 'echo "starting monitor"'
194 }
195 }
196 }
197}
198```
199
200Here we define one target, `prod`, with three processes. Each process gets its
201own upstart script, log file, and logrotate file. Deploying will restart all
202three processes at once. If you run `ggg prod <stop|restart|start>` gogogo will
203stop|restart|start all three processes at once.
204
205You can start, stop, restart or log individual processes by running
206`ggg <command> prod:<processName>`. If you wanted to restart the web process,
207you would run `ggg restart prod:web`
208
209### Plugins
210
211Plugins allow you to manipulate fields in the ggg.js file at runtime.
212
213gogogo plugins override a single deploy parameter (such as hosts) and are a
214simple file that exports a single function with the following signature:
215
216``` JavaScript
217module.exports = function(opts, cb) {
218 cb(err, overrides)
219}
220```
221where opts is a hash of user definied options, and overrides is the value to
222replace the field with.
223
224
225Currently, there is one bundled plugin, chefHosts, which integrates with
226opscode's knife to retrieve a list of servers to deploy to. An example of using
227a plugin is shown below.
228
229``` JavaScript
230plugins: {
231 "chefHosts" : {
232 overrides: "hosts", // required field! defines the property to override
233 opts: {
234 role: "myapp",
235 env: "production"
236 }
237 },
238 "./plugins/myPlugin" { // user plugins are supported, relative to cwd
239 overrides: "install"
240 }
241},
242```
243
244### Multiple servers
245
246To deploy to multiple servers, just add multiple servers to the config file
247
248``` JavaScript
249// ggg.js
250module.exports = {
251 servers: {
252 dev: "deploy@dev.mycompany.com",
253 staging: "deploy@staging.mycompany.com"
254 }
255}
256```
257
258Then deploy to them separately
259
260 gogogo deploy dev master
261 gogogo deploy staging master
262
263### Multiple branches on the same server
264
265You can deploy any branch over your old remote by pushing to it. To have
266multiple versions of an app running at the same time, call `ggg create`
267with different names and the same server.
268
269``` JavaScript
270// ggg.js
271module.exports = {
272 servers: {
273 dev: "deploy@dev.mycompany.com",
274 featurex: "deploy@dev.mycompany.com"
275 }
276}
277```
278
279Then deploy to them separately
280
281 ggg deploy dev master
282 ggg deploy featurex featurex
283
284Note that for web servers you'll want to change the port in your featurex
285branch or it will conflict.
286
287### Deploying without start
288If you want to deploy code without having to run anything (such as machines
289that only do cron) just don't define a start command or override it with an
290empty string.
291
292### SSH key host checking warning
293SSH is run with host key checking disabled. It's up to you to verify the
294authenticity of your hosts.