-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathdoc.go
221 lines (221 loc) · 6.54 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
// Package harp is a go application deploy tool (or an easy way to start go daemon or run go programs on remote servers).
//
// Please consult up-to-date README from https://github.com/bom-d-van/harp. Docs here are made for good GoDoc Searches.
//
// What Harp Does
//
// Harp simply builds your application and upload it to your server. It brings you a complete solution for deploying common applications. It syncs, restarts, kills, and deploys your applications.
//
// The best way to learn what harp does and helps is to use it. (In test directory, there are docker files and harp configurations you can play with)
//
// Usage:
//
// # Init harp.json
// harp init
//
// # Configure your servers and apps in harp.json. see section Configuration below.
// harp -s dev deploy
//
// # Or
// harp -s prod deploy
//
// # Restart server
// harp -s prod restart
//
// # Shut down server
// harp -s prod kill
//
// # Inspect server info
// harp -s prod info
//
// # Rollback release
// harp -s prod rollback $version-tag
//
// # Tail server logs
// harp -s prod log
//
// # Done. More flags and usages are in harp -v
//
// Configuration
//
// example:
//
// {
// "GOOS": "linux", // for go build
// "GOARCH": "amd64", // for go build
// "App": {
// "Name": "app",
// "ImportPath": "github.com/bom-d-van/harp/test",
//
// // these are included in all file Excludeds
// "DefaultExcludeds": [".git/", "tmp/", ".DS_Store", "node_modules/"],
// "Files": [
// // files here could be a string or an object
// "github.com/bom-d-van/harp/test/files",
// {
// "Path": "github.com/bom-d-van/harp/test/file",
// "Excludeds": ["builds"]
// }
// ]
// },
// "Servers": {
// "prod": [{
// "User": "app",
// "Host": "192.168.59.103",
// "Port": ":49155"
// }, {
// "User": "app",
// "Host": "192.168.59.104",
// "Port": ":49156"
// }],
//
// "dev": [{
// "User": "app",
// "Host": "192.168.59.102",
// "Port": ":49155"
// }]
// }
// }
//
// How to specify server or server sets:
//
// Using the configuration above as example, server set means the key in `Servers` object value, i.e. `prod`, `dev`.
// While server is elemnt in server set arrays, you can specify it by `{User}@{Host}{Port}`.
//
// # deploy prod servers
// harp -s prod deploy
//
// # deploy dev servers
// harp -s dev deploy
//
// # deploy only one prod server:
// harp -server [email protected]:49155 deploy
//
// Migration
//
// Or run a go package/file on remote server.
// You can specify server or server sets on which your migration need to be executed.
//
// Simple:
//
// harp -server [email protected]:49153 run migration.go
//
// With env and arguments:
//
// harp -server [email protected]:49153 run "AppEnv=prod migration2.go -arg1 val1 -arg2 val2"
//
// Multiple migrations:
//
// harp -server [email protected]:49153 run migration.go "AppEnv=prod migration2.go -arg1 val1 -arg2 val2"
//
// __Note__: Harp saved the current migration files in `$HOME/harp/{{.App.Name}}/migrations.tar.gz`. You can uncompress it and execute the binary manually if you prefer or on special occasions.
//
// Rollback
//
// By default harp will save three most recent releases in `$HOME/harp/{{.App.Name}}/releases` directory. The current release is the newest release in the releases list.
//
// # list all releases
// harp -s prod rollback ls
//
// # rollback
// harp -s prod rollback 15-06-14-11:29:14
//
// And there is also a `rollback.sh` script in `$HOME/harp/{{.App.Name}}` that you can use to rollback release.
//
// You can change how many releases you want to keep by `RollbackCount` or disable rollback by `NoRollback` in configs.
//
// {
// "GOOS": "linux", // for go build
// "GOARCH": "amd64", // for go build
//
// "NoRollback": true,
// "RollbackCount": 10,
//
// "App": {
// ...
// },
// ...
// }
//
// Build Override
//
// Add `BuildCmd` option in `App` as bellow:
//
// "App": {
// "Name": "app",
// "BuildCmd": "docker run -t -v $GOPATH:/home/app golang /bin/sh -c 'GOPATH=/home/app /usr/local/go/bin/go build -o path/to/app/tmp/app project/import/path'"
// }
//
// Build override is useful doing cross compilation for cgo-involved projects, e.g. using Mac OS X building Linux binaries by docker or any other tools etc.
//
// Note: harp expects build output appears in directory `tmp/{{app name}}` where you evoke harp command (i.e. pwd).
//
// Script Override
//
// harp supports you to override its default deploy script. Add configuration like bellow:
//
// "App": {
// "Name": "app",
// "DeployScript": "path-to-your-script-template"
// },
//
// The script could be a `text/template.Template`, into which harp pass a data as bellow:
//
// map[string]interface{}{
// "App": harp.App,
// "Server": harp.Server,
// "SyncFiles": syncFilesScript,
// "RestartServer": restartScript,
// }
//
// type App struct {
// Name string
// ImportPath string
// Files []string
//
// Args []string
// Envs map[string]string
//
// BuildCmd string
//
// KillSig string
//
// // TODO: could override default deploy script for out-of-band deploy
// DeployScript string
// RestartScript string
// }
//
// type Server struct {
// Envs map[string]string
// GoPath string
// LogDir string
// PIDDir string
//
// User string
// Host string
// Port string
//
// Set string
//
// client *ssh.Client
// }
//
// A default deploy script is:
//
// set -e
// {{.SyncFiles}}
// {{.RestartServer}}
//
// Similarly, restart script could be override too. And its default template is:
//
// set -e
// {{.RestartServer}}
//
// You can inspect your script by evoking command: `harp -s prod inspect deploy` or `harp -s prod inspect restart`.
//
// Cross Compilation
//
// If you need to initialize cross compilation environment, harp has a simple commend to help you:
//
// harp xc
package main