Merge lp:~cypressyew/checkbox/systemd-server into lp:checkbox

Proposed by Po-Hsu Lin
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 3746
Merged at revision: 3760
Proposed branch: lp:~cypressyew/checkbox/systemd-server
Merge into: lp:checkbox
Diff against target: 127 lines (+34/-8)
7 files modified
checkbox-ng/contrib/checkbox-ci-installed-notifier.conf (+2/-1)
checkbox-ng/contrib/checkbox-ci-installed-notifier.service (+6/-2)
checkbox-ng/contrib/checkbox-ci-mailer.conf (+1/-1)
checkbox-ng/contrib/checkbox-ci-mailer.service (+1/-1)
checkbox-ng/contrib/checkbox-sru.conf (+2/-2)
checkbox-ng/contrib/checkbox-sru.desktop (+1/-1)
checkbox-ng/contrib/checkbox-sru.service (+21/-0)
To merge this branch: bzr merge lp:~cypressyew/checkbox/systemd-server
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+258239@code.launchpad.net

Description of the change

Add the service file for systemd on Vivid server, explicitly dump the test log to /tmp with "server" in the file name to avoid confusion. (It should be further improved, e.g. by adding "desktop" to distinguish them later in bug 1451658)

The last puzzle of this is to "enable" the service file, with command: systemctl enable checkbox-sru.service, to allow it start automatically on boot.
But this may need to be done in the preseed file. Unless there is another way to run some script like what we did in desktop systems (/etc/xdg/autostart/checkbox-sru.desktop)

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

According to https://wiki.ubuntu.com/SystemdForUpstartUsers#Automatic_starting

Adding:

[Install]
WantedBy=multi-user.target

should be all that we need to enable the autostart of the checkbox service file (desktop & server)

We shouldn’t have to manually start the service in the preseed IMHO.
I'll continue testing your branch today.

Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Yes, this part is for allowing it to start automatically on boot.

But I found that we still need to enable the service file manually on first boot with "systemctl enable checkbox-sru.service" command, which will create a softlink of the service file under the "target" directory we assigned here.

Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Let's land the service file to build correctly the CI loop package and see how to start the service afterwards

review: Approve
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

The right way to enable the services would have been to use dh_systemd but this helper is not available for precise. So instead of creating post-installation scripts to enable them (that could lead to two runs on desktop systems), let's add the following lines to the server preseed:

systemctl enable checkbox-sru
systemctl enable checkbox-ci-installed-notifier

This will create the following needed symlinks in /etc/systemd/system/multi-user.target.wants:

checkbox-ci-installed-notifier.service -> /lib/systemd/system/checkbox-ci-installed-notifier.service
checkbox-sru.service -> /lib/systemd/system/checkbox-sru.service

With those symlinks, the two services are sucessfully started on boot (tested on a vivid server):

systemctl status checkbox-sru
● checkbox-sru.service - CheckBox SRU on server
   Loaded: loaded (/lib/systemd/system/checkbox-sru.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Fri 2015-05-08 16:14:31 CEST; 41s ago
  Process: 847 ExecStopPost=/bin/systemctl start checkbox-ci-mailer.service (code=exited, status=0/SUCCESS)
  Process: 831 ExecStart=/bin/systemctl start checkbox-ci-installed-notifier.service (code=exited, status=0/SUCCESS)
  Process: 827 ExecStartPre=/bin/mkdir -p /var/cache/plainbox (code=exited, status=0/SUCCESS)
 Main PID: 831 (code=exited, status=0/SUCCESS)

May 08 16:14:31 ubuntu systemd[1]: Starting CheckBox SRU on server...
May 08 16:14:31 ubuntu systemd[1]: Started CheckBox SRU on server.

Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Thanks for confirming and testing this, I will propose a MR for checkbox-satellite soon.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox-ng/contrib/checkbox-ci-installed-notifier.conf'
2--- checkbox-ng/contrib/checkbox-ci-installed-notifier.conf 2015-04-30 08:22:48 +0000
3+++ checkbox-ng/contrib/checkbox-ci-installed-notifier.conf 2015-05-05 11:07:16 +0000
4@@ -13,7 +13,8 @@
5 start on checkbox-sru-started
6
7 task
8-
9+# Note that the autostart file here for server is different
10+# in upstart and systemd version
11 env CHECKBOX_SERVER_CONF=/etc/init/checkbox-sru.conf
12 env CHECKBOX_DESKTOP_XDG=/etc/xdg/autostart/checkbox-sru.desktop
13
14
15=== modified file 'checkbox-ng/contrib/checkbox-ci-installed-notifier.service'
16--- checkbox-ng/contrib/checkbox-ci-installed-notifier.service 2015-04-30 08:22:48 +0000
17+++ checkbox-ng/contrib/checkbox-ci-installed-notifier.service 2015-05-05 11:07:16 +0000
18@@ -1,8 +1,9 @@
19 [Unit]
20 Description=CheckBox SRU mini CI notifier
21+After=network-online.target
22 # CheckBox mini CI notifier.
23 #
24-# This waits for a "checkbox-sru-started" event and then
25+# This waits for a the "Network is Online" target and then
26 # uses curl to post the test starting notification
27 # to a configurable CGI URL. The CGI can do whatever it
28 # wants, such as checking the test is run or not.
29@@ -13,8 +14,11 @@
30 [Service]
31 Type=oneshot
32 #Type=simple # It does not work with this
33-Environment=CHECKBOX_SERVER_CONF=/etc/init/checkbox-sru.conf
34+Environment=CHECKBOX_SERVER_CONF=/lib/systemd/system/checkbox-sru.service
35 Environment=CHECKBOX_DESKTOP_XDG=/etc/xdg/autostart/checkbox-sru.desktop
36 ExecStartPre=/bin/sh -ec '[ -f /etc/default/plainbox-ci-mailer ] || exit 1'
37 ExecStartPre=/bin/sh -ec '[ -x /usr/bin/curl ] || exit 1'
38 ExecStart=/usr/bin/checkbox-ci-script.sh notification
39+
40+[Install]
41+WantedBy=multi-user.target
42
43=== modified file 'checkbox-ng/contrib/checkbox-ci-mailer.conf'
44--- checkbox-ng/contrib/checkbox-ci-mailer.conf 2015-04-30 08:22:48 +0000
45+++ checkbox-ng/contrib/checkbox-ci-mailer.conf 2015-05-05 11:07:16 +0000
46@@ -14,7 +14,7 @@
47
48 task
49
50-env CHECKBOX_UPSTART_LOG=/var/log/upstart/checkbox-sru.log
51+env CHECKBOX_UPSTART_LOG=/tmp/checkbox-server.log
52 env CHECKBOX_DESKTOP_LOG=/tmp/checkbox.log
53
54 pre-start script
55
56=== modified file 'checkbox-ng/contrib/checkbox-ci-mailer.service'
57--- checkbox-ng/contrib/checkbox-ci-mailer.service 2015-04-30 08:22:48 +0000
58+++ checkbox-ng/contrib/checkbox-ci-mailer.service 2015-05-05 11:07:16 +0000
59@@ -14,7 +14,7 @@
60 [Service]
61 Type=oneshot
62 #Type=simple # It does not work with this
63-Environment=CHECKBOX_UPSTART_LOG=/var/log/upstart/checkbox-sru.log
64+Environment=CHECKBOX_UPSTART_LOG=/tmp/checkbox-server.log
65 Environment=CHECKBOX_DESKTOP_LOG=/tmp/checkbox.log
66 ExecStartPre=/bin/sh -ec '[ -f /etc/default/plainbox-ci-mailer ] || exit 1'
67 ExecStartPre=/bin/sh -ec '[ -x /usr/bin/curl ] || exit 1'
68
69=== modified file 'checkbox-ng/contrib/checkbox-sru.conf'
70--- checkbox-ng/contrib/checkbox-sru.conf 2015-04-06 06:54:52 +0000
71+++ checkbox-ng/contrib/checkbox-sru.conf 2015-05-05 11:07:16 +0000
72@@ -3,7 +3,7 @@
73 # Run SRU testing with CheckBoxNG 60 seconds after networking
74 # has started to wait for DHCP to complete.
75
76-description "CheckBox SRU"
77+description "CheckBox SRU on server"
78
79 # Make sure we start after networking
80 start on runlevel [2345]
81@@ -22,7 +22,7 @@
82
83 script
84 initctl emit checkbox-sru-started
85- exec /usr/bin/checkbox sru
86+ exec /usr/bin/checkbox sru > /tmp/checkbox-server.log 2>&1
87 end script
88
89 post-stop script
90
91=== modified file 'checkbox-ng/contrib/checkbox-sru.desktop'
92--- checkbox-ng/contrib/checkbox-sru.desktop 2015-05-04 07:40:12 +0000
93+++ checkbox-ng/contrib/checkbox-sru.desktop 2015-05-05 11:07:16 +0000
94@@ -1,6 +1,6 @@
95 [Desktop Entry]
96 Encoding=UTF-8
97-Name=CheckBox SRU
98+Name=CheckBox SRU for Desktop
99 Comment=CheckBox can run after login to test a system automatically.
100 Icon=checkbox
101 Exec=sh -c "pidof systemd && { sudo systemctl start checkbox-ci-installed-notifier.service; /usr/bin/checkbox sru --check-config >/tmp/checkbox.log 2>&1; sudo systemctl start checkbox-ci-mailer.service; } || { sudo initctl emit checkbox-sru-started; /usr/bin/checkbox sru --check-config >/tmp/checkbox.log 2>&1; sudo initctl emit checkbox-sru-finished; }"
102
103=== added file 'checkbox-ng/contrib/checkbox-sru.service'
104--- checkbox-ng/contrib/checkbox-sru.service 1970-01-01 00:00:00 +0000
105+++ checkbox-ng/contrib/checkbox-sru.service 2015-05-05 11:07:16 +0000
106@@ -0,0 +1,21 @@
107+[Unit]
108+Description=CheckBox SRU on server
109+After=network-online.target
110+After=checkbox-ci-installed-notifier.service
111+# checkbox sru - Run CheckBox SRU tests after booting
112+#
113+# Run SRU testing with CheckBoxNG after networking
114+# has started and connection available.
115+
116+[Service]
117+Type=oneshot
118+ExecStartPre=/bin/sh -c "/usr/bin/checkbox check-config || exit 1"
119+ExecStartPre=/bin/mkdir -p /var/cache/plainbox
120+ExecStart=/bin/systemctl start checkbox-ci-installed-notifier.service
121+ExecStart=/bin/sh -c "/usr/bin/checkbox sru > /tmp/checkbox-server.log 2>&1"
122+ExecStopPost=/bin/systemctl start checkbox-ci-mailer.service
123+
124+[Install]
125+# This is roughly equivalent to "start on runlevel [2345]"
126+WantedBy=multi-user.target
127+#stop on runlevel [!023456]

Subscribers

People subscribed via source and target branches