-
Notifications
You must be signed in to change notification settings - Fork 1
/
simple_deploy.go
68 lines (60 loc) · 2.1 KB
/
simple_deploy.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
package main
import (
"github.com/chriswalz/simple-deploy/os_agnostic/deploy"
"github.com/urfave/cli"
"log"
"os"
"strings"
)
// easiest way to daemonize a go app?
// update readme with gif on how to use
// update readme with setup guide
func main() {
log.SetFlags(log.Lshortfile)
var binaryName = "app"
var appName = "sdapp"
// todo add "STATUS" section
app := cli.NewApp()
app.Name = "Simple Deploy"
app.Usage = "Fast and simple deploy to unix server"
app.Version = "0.7.1"
app.Action = func(c *cli.Context) error {
if c.Args().Get(0) == "logs" {
if len(c.Args()) < 2 {
return cli.NewExitError("Error: missing host address\nUsage: simple-deploy logs <host>\nExample: simple-deploy logs [email protected]", 1)
}
user, address := deploy.GetSSHArgs(c.Args().Get(1))
buddy := deploy.SetupClient(user, address)
buddy.RunCmdRemotely("supervisorctl tail -5000 goapp stdout; supervisorctl tail -5000 goapp stderr")
return nil
}
if c.Args().Get(0) == "upload-supervisor-config" {
if len(c.Args()) < 3 {
return cli.NewExitError("Error: missing host address\nUsage: simple-deploy upload-supervisor-config <host> <config>\nExample: simple-deploy upload-supervisor-config [email protected] configs/app.conf", 1)
}
user, address := deploy.GetSSHArgs(c.Args().Get(1))
buddy := deploy.SetupClient(user, address)
buddy.CopySupervisorConfigToRemote(c.Args().Get(2))
return nil
}
if c.Args().Get(0) == "docker" {
if len(c.Args()) < 3 {
return cli.NewExitError("Error: missing host address\nUsage: simple-deploy docker <host> <images>\nExample: simple-deploy docker [email protected] redis,mysql", 1)
}
user, address := deploy.GetSSHArgs(c.Args().Get(1))
buddy := deploy.SetupClient(user, address)
images := strings.Split(c.Args().Get(2), ",")
buddy.InstallDockerOnUbuntu(images)
return nil
}
user, address := deploy.GetSSHArgs(c.Args().Get(0))
buddy := deploy.SetupClient(user, address)
paths := strings.Split(c.Args().Get(1), ",")
buddy.Deploy(binaryName, appName, user, address, paths)
return nil
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}