LEFT | RIGHT |
(no file at all) | |
1 package upstart | 1 package upstart |
2 | 2 |
3 import ( | 3 import ( |
4 "bytes" | 4 "bytes" |
5 "errors" | 5 "errors" |
6 "fmt" | 6 "fmt" |
7 "io/ioutil" | 7 "io/ioutil" |
8 "os" | 8 "os" |
9 "os/exec" | 9 "os/exec" |
10 "path" | 10 "path" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // (as used by upstart); this may become an issue in the future. | 89 // (as used by upstart); this may become an issue in the future. |
90 var confT = template.Must(template.New("").Parse(` | 90 var confT = template.Must(template.New("").Parse(` |
91 description "{{.Desc}}" | 91 description "{{.Desc}}" |
92 author "Juju Team <juju@lists.ubuntu.com>" | 92 author "Juju Team <juju@lists.ubuntu.com>" |
93 start on runlevel [2345] | 93 start on runlevel [2345] |
94 stop on runlevel [!2345] | 94 stop on runlevel [!2345] |
95 respawn | 95 respawn |
96 normal exit 0 | 96 normal exit 0 |
97 {{range $k, $v := .Env}}env {{$k}}={{$v|printf "%q"}} | 97 {{range $k, $v := .Env}}env {{$k}}={{$v|printf "%q"}} |
98 {{end}} | 98 {{end}} |
99 {{range $k, $v := .Limit}}limit {{$k}} {{$v|printf "%s"}} | 99 {{range $k, $v := .Limit}}limit {{$k}} {{$v}} |
100 {{end}} | 100 {{end}} |
101 exec {{.Cmd}}{{if .Out}} >> {{.Out}} 2>&1{{end}} | 101 exec {{.Cmd}}{{if .Out}} >> {{.Out}} 2>&1{{end}} |
102 `[1:])) | 102 `[1:])) |
103 | 103 |
104 // Conf is responsible for defining and installing upstart services. Its fields | 104 // Conf is responsible for defining and installing upstart services. Its fields |
105 // represent elements of an upstart service configuration file. | 105 // represent elements of an upstart service configuration file. |
106 type Conf struct { | 106 type Conf struct { |
107 Service | 107 Service |
108 // Desc is the upstart service's description. | 108 // Desc is the upstart service's description. |
109 Desc string | 109 Desc string |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 func (c *Conf) InstallCommands() ([]string, error) { | 169 func (c *Conf) InstallCommands() ([]string, error) { |
170 conf, err := c.render() | 170 conf, err := c.render() |
171 if err != nil { | 171 if err != nil { |
172 return nil, err | 172 return nil, err |
173 } | 173 } |
174 return []string{ | 174 return []string{ |
175 fmt.Sprintf("cat >> %s << 'EOF'\n%sEOF\n", c.confPath(), conf), | 175 fmt.Sprintf("cat >> %s << 'EOF'\n%sEOF\n", c.confPath(), conf), |
176 "start " + c.Name, | 176 "start " + c.Name, |
177 }, nil | 177 }, nil |
178 } | 178 } |
LEFT | RIGHT |