Merge lp:~mvo/snappy/15.04-lp1490574-systemd-type-forking into lp:~snappy-dev/snappy/15.04-deprecated

Proposed by Michael Vogt
Status: Merged
Approved by: Michael Vogt
Approved revision: 470
Merged at revision: 478
Proposed branch: lp:~mvo/snappy/15.04-lp1490574-systemd-type-forking
Merge into: lp:~snappy-dev/snappy/15.04-deprecated
Diff against target: 104 lines (+34/-7)
5 files modified
docs/meta.md (+3/-1)
snappy/click.go (+1/-0)
snappy/click_test.go (+25/-4)
snappy/snapp.go (+1/-0)
systemd/systemd.go (+4/-2)
To merge this branch: bzr merge lp:~mvo/snappy/15.04-lp1490574-systemd-type-forking
Reviewer Review Type Date Requested Status
Michael Vogt (community) Approve
John Lenton (community) Approve
Review via email: mp+270357@code.launchpad.net

Commit message

Add support for "forking"

Description of the change

Backport of the trunk branch that adds "type: forking" to the services yaml to support daemons that fork with systemd.

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) :
review: Approve
Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :

Attempt to merge into lp:snappy/15.04 failed due to conflicts:

text conflict in snappy/click.go
text conflict in snappy/click_test.go
text conflict in systemd/systemd.go

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :

Attempt to merge into lp:snappy/15.04 failed due to conflicts:

text conflict in snappy/click.go
text conflict in snappy/click_test.go
text conflict in systemd/systemd.go

470. By Michael Vogt

merged lp:snappy/15.04 and resolved conflicts

Revision history for this message
Michael Vogt (mvo) wrote :

Fixed now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/meta.md'
2--- docs/meta.md 2015-09-08 06:47:10 +0000
3+++ docs/meta.md 2015-09-11 19:56:24 +0000
4@@ -46,7 +46,9 @@
5 * `stop`: (optional) the command to stop the service
6 * `stop-timeout`: (optional) the time in seconds to wait for the
7 service to stop
8- * `poststop`: a command that runs after the service has stopped
9+ * `poststop`: (optional) a command that runs after the service has stopped
10+ * `forking`: (optional) set to "true" if the service calls fork() as
11+ part of its startup
12 * `caps`: (optional) list of additional security policies to add.
13 See `security.md` for details
14 * `security-template`: (optional) alternate security template to use
15
16=== modified file 'snappy/click.go'
17--- snappy/click.go 2015-09-08 06:47:10 +0000
18+++ snappy/click.go 2015-09-11 19:56:24 +0000
19@@ -530,6 +530,7 @@
20 IsFramework: m.Type == SnapTypeFramework,
21 IsNetworked: service.Ports != nil && len(service.Ports.External) > 0,
22 BusName: service.BusName,
23+ Forking: service.Forking,
24 UdevAppName: udevPartName,
25 Socket: service.Socket,
26 SocketFileName: socketFileName,
27
28=== modified file 'snappy/click_test.go'
29--- snappy/click_test.go 2015-09-09 07:59:00 +0000
30+++ snappy/click_test.go 2015-09-11 19:56:24 +0000
31@@ -1200,12 +1200,33 @@
32 [Install]
33 WantedBy=multi-user.target
34 `
35- expectedServiceAppWrapper = fmt.Sprintf(expectedServiceWrapperFmt, "After=ubuntu-snappy.frameworks.target\nRequires=ubuntu-snappy.frameworks.target", ".canonical", "canonical", "\n", helpers.UbuntuArchitecture())
36- expectedNetAppWrapper = fmt.Sprintf(expectedServiceWrapperFmt, "After=ubuntu-snappy.frameworks.target\nRequires=ubuntu-snappy.frameworks.target\nAfter=snappy-wait4network.service\nRequires=snappy-wait4network.service", ".canonical", "canonical", "\n", helpers.UbuntuArchitecture())
37- expectedServiceFmkWrapper = fmt.Sprintf(expectedServiceWrapperFmt, "Before=ubuntu-snappy.frameworks.target\nAfter=ubuntu-snappy.frameworks-pre.target\nRequires=ubuntu-snappy.frameworks-pre.target", "", "", "BusName=foo.bar.baz\nType=dbus", helpers.UbuntuArchitecture())
38- expectedSocketUsingWrapper = fmt.Sprintf(expectedServiceWrapperFmt, "After=ubuntu-snappy.frameworks.target xkcd-webserver_xkcd-webserver_0.3.4.socket\nRequires=ubuntu-snappy.frameworks.target xkcd-webserver_xkcd-webserver_0.3.4.socket", ".canonical", "canonical", "\n", helpers.UbuntuArchitecture())
39+ expectedServiceAppWrapper = fmt.Sprintf(expectedServiceWrapperFmt, "After=ubuntu-snappy.frameworks.target\nRequires=ubuntu-snappy.frameworks.target", ".canonical", "canonical", "\n", helpers.UbuntuArchitecture())
40+ expectedNetAppWrapper = fmt.Sprintf(expectedServiceWrapperFmt, "After=ubuntu-snappy.frameworks.target\nRequires=ubuntu-snappy.frameworks.target\nAfter=snappy-wait4network.service\nRequires=snappy-wait4network.service", ".canonical", "canonical", "\n", helpers.UbuntuArchitecture())
41+ expectedServiceFmkWrapper = fmt.Sprintf(expectedServiceWrapperFmt, "Before=ubuntu-snappy.frameworks.target\nAfter=ubuntu-snappy.frameworks-pre.target\nRequires=ubuntu-snappy.frameworks-pre.target", "", "", "BusName=foo.bar.baz\nType=dbus", helpers.UbuntuArchitecture())
42+ expectedSocketUsingWrapper = fmt.Sprintf(expectedServiceWrapperFmt, "After=ubuntu-snappy.frameworks.target xkcd-webserver_xkcd-webserver_0.3.4.socket\nRequires=ubuntu-snappy.frameworks.target xkcd-webserver_xkcd-webserver_0.3.4.socket", ".canonical", "canonical", "\n", helpers.UbuntuArchitecture())
43+ expectedTypeForkingFmkWrapper = fmt.Sprintf(expectedServiceWrapperFmt, "After=ubuntu-snappy.frameworks.target\nRequires=ubuntu-snappy.frameworks.target", ".canonical", "canonical", "Type=forking\n", helpers.UbuntuArchitecture())
44 )
45
46+func (s *SnapTestSuite) TestSnappyGenerateSnapServiceTypeForking(c *C) {
47+ service := Service{
48+ Name: "xkcd-webserver",
49+ Start: "bin/foo start",
50+ Stop: "bin/foo stop",
51+ PostStop: "bin/foo post-stop",
52+ StopTimeout: DefaultTimeout,
53+ Description: "A fun webserver",
54+ Forking: true,
55+ }
56+ pkgPath := "/apps/xkcd-webserver.canonical/0.3.4/"
57+ aaProfile := "xkcd-webserver.canonical_xkcd-webserver_0.3.4"
58+ m := packageYaml{Name: "xkcd-webserver",
59+ Version: "0.3.4"}
60+
61+ generatedWrapper, err := generateSnapServicesFile(service, pkgPath, aaProfile, &m)
62+ c.Assert(err, IsNil)
63+ c.Assert(generatedWrapper, Equals, expectedTypeForkingFmkWrapper)
64+}
65+
66 func (s *SnapTestSuite) TestSnappyGenerateSnapServiceAppWrapper(c *C) {
67 service := Service{
68 Name: "xkcd-webserver",
69
70=== modified file 'snappy/snapp.go'
71--- snappy/snapp.go 2015-09-08 06:47:10 +0000
72+++ snappy/snapp.go 2015-09-11 19:56:24 +0000
73@@ -145,6 +145,7 @@
74 PostStop string `yaml:"poststop,omitempty" json:"poststop,omitempty"`
75 StopTimeout Timeout `yaml:"stop-timeout,omitempty" json:"stop-timeout,omitempty"`
76 BusName string `yaml:"bus-name,omitempty" json:"bus-name,omitempty"`
77+ Forking bool `yaml:"forking,omitempty" json:"forking,omitempty"`
78
79 // set to yes if we need to create a systemd socket for this service
80 Socket bool `yaml:"socket,omitempty" json:"socket,omitempty"`
81
82=== modified file 'systemd/systemd.go'
83--- systemd/systemd.go 2015-09-09 07:59:00 +0000
84+++ systemd/systemd.go 2015-09-11 19:56:24 +0000
85@@ -84,6 +84,7 @@
86 IsFramework bool
87 IsNetworked bool
88 BusName string
89+ Forking bool
90 UdevAppName string
91 Socket bool
92 SocketFileName string
93@@ -199,8 +200,9 @@
94 {{if .Stop}}ExecStop=/usr/bin/ubuntu-core-launcher {{.UdevAppName}} {{.AaProfile}} {{.FullPathStop}}{{end}}
95 {{if .PostStop}}ExecStopPost=/usr/bin/ubuntu-core-launcher {{.UdevAppName}} {{.AaProfile}} {{.FullPathPostStop}}{{end}}
96 {{if .StopTimeout}}TimeoutStopSec={{.StopTimeout.Seconds}}{{end}}
97-{{if .BusName}}BusName={{.BusName}}{{end}}
98-{{if .BusName}}Type=dbus{{end}}
99+{{if .BusName}}BusName={{.BusName}}
100+Type=dbus{{else}}{{if .Forking}}Type=forking{{end}}
101+{{end}}
102
103 [Install]
104 WantedBy={{.ServiceSystemdTarget}}

Subscribers

People subscribed via source and target branches