Merge lp:~larryprice/libertine/libertined-systemd into lp:libertine

Proposed by Larry Price
Status: Merged
Approved by: Christopher Townsend
Approved revision: 420
Merged at revision: 456
Proposed branch: lp:~larryprice/libertine/libertined-systemd
Merge into: lp:libertine
Diff against target: 220 lines (+40/-102)
7 files modified
data/CMakeLists.txt (+5/-0)
data/com.canonical.libertine.Service.service (+2/-1)
data/libertine.service (+7/-0)
debian/libertined.install (+1/-0)
tests/integration/test_libertine_service.py (+1/-1)
tests/integration/test_liblibertine.cpp (+0/-1)
tools/libertined (+24/-99)
To merge this branch: bzr merge lp:~larryprice/libertine/libertined-systemd
Reviewer Review Type Date Requested Status
Christopher Townsend Approve
Libertine CI Bot continuous-integration Approve
Review via email: mp+321780@code.launchpad.net

Commit message

Install libertined as systemd unit.

Description of the change

Install libertined as systemd unit.

To post a comment you must log in.
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:417
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/506/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/911
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/747
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=zesty,testname=default/747
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/747
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=zesty,testname=default/747
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/922
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/911
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/911/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/911
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/911/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/911
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/911/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/911
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/911/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/506/rebuild

review: Approve (continuous-integration)
418. By Larry Price

attempt on dealing with systemd install/remove

419. By Larry Price

merge

420. By Larry Price

minor change

Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:420
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/508/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/913
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/749
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=zesty,testname=default/749
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/749
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=zesty,testname=default/749
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/924
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/913
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/913/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/913
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/913/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/913
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/913/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/913
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/913/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/508/rebuild

review: Approve (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

lgtm, +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/CMakeLists.txt'
2--- data/CMakeLists.txt 2017-01-31 16:28:31 +0000
3+++ data/CMakeLists.txt 2017-04-04 18:44:41 +0000
4@@ -8,5 +8,10 @@
5 DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)
6 install(FILES libertine-lxc-sudo libertine-lxd-sudo
7 DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/sudoers.d)
8+
9+# libertined
10 install(FILES com.canonical.libertine.Service.service
11 DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services)
12+pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir)
13+install(FILES libertine.service
14+ DESTINATION ${SYSTEMD_USER_DIR}/)
15
16=== modified file 'data/com.canonical.libertine.Service.service'
17--- data/com.canonical.libertine.Service.service 2017-01-20 20:37:02 +0000
18+++ data/com.canonical.libertine.Service.service 2017-04-04 18:44:41 +0000
19@@ -1,3 +1,4 @@
20 [D-BUS Service]
21 Name=com.canonical.libertine.Service
22-Exec=/usr/bin/libertined --cache-output
23+Exec=/usr/bin/libertined
24+SystemdService=libertine.service
25
26=== added file 'data/libertine.service'
27--- data/libertine.service 1970-01-01 00:00:00 +0000
28+++ data/libertine.service 2017-04-04 18:44:41 +0000
29@@ -0,0 +1,7 @@
30+[Unit]
31+Description=Libertine Service
32+
33+[Service]
34+Type=dbus
35+BusName=com.canonical.libertine.Service
36+ExecStart=/usr/bin/libertined
37
38=== modified file 'debian/libertined.install'
39--- debian/libertined.install 2017-01-20 18:43:08 +0000
40+++ debian/libertined.install 2017-04-04 18:44:41 +0000
41@@ -1,3 +1,4 @@
42 usr/bin/libertined
43 usr/lib/python*/*/libertine/service
44 usr/share/dbus-1/services/com.canonical.libertine.Service.service
45+usr/lib/systemd/user
46
47=== modified file 'tests/integration/test_libertine_service.py'
48--- tests/integration/test_libertine_service.py 2017-03-27 20:51:17 +0000
49+++ tests/integration/test_libertine_service.py 2017-04-04 18:44:41 +0000
50@@ -43,7 +43,7 @@
51 cls._tempdir = tempfile.TemporaryDirectory()
52
53 os.environ['XDG_DATA_HOME'] = cls._tempdir.name
54- cls._process = pexpect.spawnu('libertined --debug', env=os.environ.copy())
55+ cls._process = pexpect.spawnu('libertined', env=os.environ.copy())
56 cls._process.logfile = sys.stdout
57
58 # give libertined enough time to start the whole process
59
60=== modified file 'tests/integration/test_liblibertine.cpp'
61--- tests/integration/test_liblibertine.cpp 2017-03-07 18:38:05 +0000
62+++ tests/integration/test_liblibertine.cpp 2017-04-04 18:44:41 +0000
63@@ -30,7 +30,6 @@
64 static void SetUpTestCase()
65 {
66 process = dbus_test_process_new("libertined");
67- dbus_test_process_append_param(process, "--debug");
68
69 dbus_test_task_set_bus(DBUS_TEST_TASK(process), DBUS_TEST_SERVICE_BUS_SESSION);
70 dbus_test_task_set_name(DBUS_TEST_TASK(process), "libertine");
71
72=== modified file 'tools/libertined'
73--- tools/libertined 2017-03-27 20:06:39 +0000
74+++ tools/libertined 2017-04-04 18:44:41 +0000
75@@ -28,89 +28,15 @@
76 from libertine.service import constants, operations, container_control, container_control_client
77
78
79-class OutputRedirector(object):
80- def __init__(self, config):
81- self.config = config
82- if utils.is_snap_environment():
83- self.cache_path = '%s/.cache/libertined' % os.environ['SNAP_USER_COMMON']
84- else:
85- self.cache_path = '%s/.cache/libertined' % os.environ['HOME']
86- self.cache_file = '%s/libertined.log' % self.cache_path
87- self.output_file = None
88- self.copied_stdout = None
89- self.copied_stderr = None
90-
91- def _fileno(self, file_or_fd):
92- return getattr(file_or_fd, 'fileno', lambda: file_or_fd)()
93-
94- def _do_redirect(self, stream):
95- fd = self._fileno(stream)
96- copied_stream = os.fdopen(os.dup(fd), 'wb')
97- stream.flush()
98- os.dup2(self._fileno(self.output_file), fd)
99- return copied_stream, fd
100-
101- def _undo_redirect(self, stream, stream_fd, copied_stream):
102- stream.flush()
103- os.dup2(copied_stream.fileno(), stream_fd)
104- copied_stream.close()
105-
106- def _rotate_logs(self):
107- os.makedirs(self.cache_path, exist_ok=True)
108- num_backups = 3
109- for i in range(num_backups, 0, -1):
110- filename = '%s.%i' % (self.cache_file, i)
111- if os.path.exists(filename):
112- if i == num_backups:
113- os.remove(filename)
114- else:
115- os.rename(filename, '%s.%i' % (self.cache_file, i+1))
116- if os.path.exists(self.cache_file):
117- os.rename(self.cache_file, '%s.1' % self.cache_file)
118-
119- def __enter__(self):
120- utils.set_environmental_verbosity(self.config.verbosity)
121-
122- if not self.config.debug:
123- if self.config.cache_output:
124- self._rotate_logs()
125- self.output_file = open(self.cache_file, 'w')
126- else:
127- self.output_file = open(os.devnull, 'w')
128-
129- self.copied_stdout, self.stdout_fd = self._do_redirect(sys.stdout)
130- self.copied_stderr, self.stderr_fd = self._do_redirect(sys.stderr)
131-
132- def __exit__(self, type, value, tb):
133- if self.copied_stdout and self.stdout_fd:
134- self._undo_redirect(sys.stdout, self.stdout_fd, self.copied_stdout)
135- if self.copied_stderr and self.stderr_fd:
136- self._undo_redirect(sys.stderr, self.stderr_fd, self.copied_stderr)
137- if self.output_file:
138- self.output_file.close()
139-
140-
141 class Config(object):
142 def __init__(self):
143 self._arg_parser = argparse.ArgumentParser(description=u'Libertine Store service')
144- self._arg_parser.add_argument(u'-l', u"--use-local-cache",
145- action='store_true',
146- default=False,
147- help=u"use local cache instead of system cache")
148- self._arg_parser.add_argument(u'-d', u"--debug",
149- action='store_true',
150- default=False,
151- help=u"print output to stdout")
152 self._arg_parser.add_argument('-q', '--quiet', action='store_const',
153 dest='verbosity', const=0,
154 help=('disables all non-vital output'))
155 self._arg_parser.add_argument('-v', '--verbosity', action='store_const',
156 dest='verbosity', const=2,
157 help=('enables debug output'))
158- self._arg_parser.add_argument(u'-c', u"--cache-output",
159- action='store_true',
160- default=False,
161- help=u"Log to $HOME/.cache/libertined/ instead of stdout")
162 args = self._arg_parser.parse_args(namespace=Config)
163
164
165@@ -139,31 +65,30 @@
166 def main():
167 config = Config()
168
169- with OutputRedirector(config):
170- utils.get_logger().info("Initializing libertined...")
171- loop = Loop()
172-
173- try:
174- bus_name = dbus.service.BusName(constants.SERVICE_NAME,
175- bus=dbus.SessionBus(),
176- do_not_queue=True)
177- except dbus.exceptions.NameExistsException:
178- utils.get_logger().warning("service is already running")
179- raise
180-
181- client = container_control_client.ContainerControlClient()
182- manager = operations.Operations(bus_name, client)
183- container_control.ContainerControl(manager.connection, client)
184-
185- try:
186- utils.get_logger().info("libertined ready")
187- loop.run()
188- except KeyboardInterrupt:
189- utils.get_logger().debug("keyboard interrupt received")
190- except Exception as e:
191- utils.get_logger().error("Unexpected exception occurred: '{}'".format(str(e)))
192- finally:
193- loop.shutdown()
194+ utils.get_logger().info("Initializing libertined...")
195+ loop = Loop()
196+
197+ try:
198+ bus_name = dbus.service.BusName(constants.SERVICE_NAME,
199+ bus=dbus.SessionBus(),
200+ do_not_queue=True)
201+ except dbus.exceptions.NameExistsException:
202+ utils.get_logger().warning("service is already running")
203+ raise
204+
205+ client = container_control_client.ContainerControlClient()
206+ manager = operations.Operations(bus_name, client)
207+ container_control.ContainerControl(manager.connection, client)
208+
209+ try:
210+ utils.get_logger().info("libertined ready")
211+ loop.run()
212+ except KeyboardInterrupt:
213+ utils.get_logger().debug("keyboard interrupt received")
214+ except Exception as e:
215+ utils.get_logger().error("Unexpected exception occurred: '{}'".format(str(e)))
216+ finally:
217+ loop.shutdown()
218
219
220 if __name__ == '__main__':

Subscribers

People subscribed via source and target branches