1 | Go Go Go
|
2 | ========
|
3 |
|
4 | Gogogo 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 |
|
8 | 1. Easy to setup
|
9 | 2. Easy to redeploy
|
10 | 3. Deploy to multiple servers
|
11 | 4. Deploy different branches to the same server
|
12 |
|
13 | Installation
|
14 | ------------
|
15 |
|
16 | npm -g install gogogo
|
17 |
|
18 | Change 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 |
|
29 | Server Requirements
|
30 | -------------------
|
31 |
|
32 | 1. Upstart (included with ubuntu)
|
33 | 2. SSH Access
|
34 | 3. Git installed on both local computer and server
|
35 | 4. for non-root users, sudo must work without a password
|
36 |
|
37 | Usage
|
38 | -----
|
39 |
|
40 | In your local repo
|
41 |
|
42 | 1. `gogogo init`
|
43 |
|
44 | 2. edit ggg.js:
|
45 |
|
46 | ``` JavaScript
|
47 | module.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 |
|
76 | 3. 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 |
|
88 | As of 0.4.0, gogogo supports plugins to help your deploys be more dynamic.
|
89 |
|
90 | gogogo plugins override a single deploy parameter (such as hosts) and are a simple
|
91 | file that exports a single function with the following signature:
|
92 |
|
93 | ``` JavaScript
|
94 | module.exports = function(opts, cb) {
|
95 | ...
|
96 | cb(err, overrides)
|
97 | }
|
98 | ```
|
99 | where opts is a hash of user definied options
|
100 |
|
101 |
|
102 | Currently, there is one bundled plugin, chefHosts, which integrates with opscode's knife to
|
103 | retrieve a list of servers to deploy too. Example of using a plugin is show below
|
104 |
|
105 | ``` JavaScript
|
106 | ...
|
107 | plugins: {
|
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 |
|
123 | Limitations
|
124 | -----------
|
125 |
|
126 | 1. Only works on ubuntu (requires upstart to be installed)
|
127 | 2. You must change the port in either the code or an environment variable to run the same app twice on the same server
|
128 |
|
129 | Roadmap
|
130 | -------
|
131 |
|
132 | * gogogo rm
|
133 | * gogogo ps
|
134 | * ability to specify sub-folders that contain package.json files
|
135 |
|
136 | Help
|
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 |
|
156 | Gogogo 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 |
|
167 | It will create a script in /etc/cron.d/, set the permissions correctly, and redirect log output to `cron.txt`
|
168 |
|
169 | ### Environment variables
|
170 |
|
171 | If 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 |
|
175 | If 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 |
|
182 | To 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 |
|
194 | Then deploy to them separately
|
195 |
|
196 | gogogo deploy dev master
|
197 | gogogo deploy staging master
|
198 |
|
199 | ### Multiple branches on the same server
|
200 |
|
201 | You 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 |
|
213 | Then deploy to them separately
|
214 |
|
215 | gogogo deploy dev master
|
216 | gogogo deploy featurex featurex
|
217 |
|
218 | Note that for web servers you'll want to change the port in your featurex branch or it will conflict.
|
219 |
|
220 | ### Reinstall / Upgrade
|
221 |
|
222 | To reinstall, run `npm install -g gogogo` again, then redo the create step in your repository.
|
223 |
|
224 | ### Gitignore
|
225 |
|
226 | Commit ggg.js to your repo, so anyone using the repo can deploy as long as they have ssh access to the server.
|
227 |
|
228 | ### Deploying without start
|
229 | If you want to deploy code without having to run anything (such as machines that only do cron) just define no
|
230 | start command (or override it with an empty string)
|
231 |
|
232 | ### IMPORTANT NOTES!
|
233 |
|
234 | SSH is run with host key checking disabled! Its up to you to verify the authenticity of your hosts!
|
235 |
|
236 |
|