<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
I had a quick glance but didn't actually test...<br>
<br>
1) please open a pull request on github, you will have more feedback
that way<br>
2) you probably want to add Alias=display-manager.service, so it can
pull it other graphical services<br>
<br>
Regards<br>
Jérémy<br>
<br>
<div class="moz-cite-prefix">On 28/11/2017 11:14, Pekka Paalanen
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:20171128101429.22298-1-ppaalanen@gmail.com">
<pre wrap="">From: Pekka Paalanen <a class="moz-txt-link-rfc2396E" href="mailto:pekka.paalanen@collabora.co.uk"><pekka.paalanen@collabora.co.uk></a>
There are many bad and even worse attempts to make Weston run as a
systemd service, and very few good ones. Let's add a good one as an
example in upstream: does not use weston-launch, does not run weston as
root, does not need wrapper scripts, and relies on logind and PAM.
This example has been composed from a couple of real-world Weston unit
files used in production. It has not been used verbatim, but it has been
briefly tested on one Yocto-based system.
The service file is not installed by the build. It would likely need
small adjustments for each distribution or system to be deplyed on.
The session-c1.scope workaround refers to a systemd bug that has been
said to be hard to reproduce, but the details have been lost in time.
Fixes: <a class="moz-txt-link-freetext" href="https://phabricator.freedesktop.org/T63">https://phabricator.freedesktop.org/T63</a>
Cc: <a class="moz-txt-link-abbreviated" href="mailto:martyn.welch@collabora.co.uk">martyn.welch@collabora.co.uk</a>
Cc: <a class="moz-txt-link-abbreviated" href="mailto:fabien.lahoudere@collabora.co.uk">fabien.lahoudere@collabora.co.uk</a>
Cc: <a class="moz-txt-link-abbreviated" href="mailto:matt.hoosier@gmail.com">matt.hoosier@gmail.com</a>
Cc: <a class="moz-txt-link-abbreviated" href="mailto:sjoerd.simons@collabora.co.uk">sjoerd.simons@collabora.co.uk</a>
Signed-off-by: Pekka Paalanen <a class="moz-txt-link-rfc2396E" href="mailto:pekka.paalanen@collabora.co.uk"><pekka.paalanen@collabora.co.uk></a>
---
Hi all,
I have cross-posted this patch to systemd-devel with the hope that
someone would recall details about the systemd or PAM plugin race that
prompted the session-c1.scope workaround. I belive Martyn spoke about it
in person with Lennart, but as far as Martyn recalls, there is no record
of the issue. Enabling session lingering was mentioned as another
workaround.
---
doc/systemd/README | 45 +++++++++++++++++++++++++++++++
doc/systemd/weston.service | 66 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 111 insertions(+)
create mode 100644 doc/systemd/README
create mode 100644 doc/systemd/weston.service
diff --git a/doc/systemd/README b/doc/systemd/README
new file mode 100644
index 00000000..2aa3aa9a
--- /dev/null
+++ b/doc/systemd/README
@@ -0,0 +1,45 @@
+ Systemd integration examples
+
+These examples rely on Weston's logind and systemd support. Weston needs to be
+built with options: --enable-dbus --enable-systemd-login --enable-systemd-notify
+
+Furthermore, Weston needs to be configured to load systemd-notify.so plugin.
+This can be done on the Weston command line:
+
+$ weston --modules=systemd-notify.so
+
+or in weston.ini:
+
+[core]
+modules=systemd-notify.so
+
+The plugin implements the systemd service notification protocol, watchdog
+protocol, and also allows socket activation and configuring listening sockets
+via systemd.
+
+
+ weston.service
+
+An example on how to run Weston as a system service. It starts a full user
+session of the named user on the given virtual terminal.
+
+This is useful for running a login manager or for dedicated systems that do not
+have personal user accounts and do not need the user to log in.
+
+You should very least customize the user, but likely also the tty and
+and the weston command line. See 'systemctl edit' command for an easy way to
+do that per-system if you don't edit the service file before installing it.
+
+This approach has an issue that in one system was worked around with the
+"After=session-c1.scope" directive. The details have been forgotten, but
+enabling session lingering was mentioned as another workaround. It might
+perhaps have something to do with multiple system units triggering the setup
+of a user session. It would be much better to start Weston as a systemd user
+service instead to avoid the issue completely.
+
+
+TODO: add an example of socket activation and defining sockets with systemd
+
+TODO: talk about starting Weston as a systemd user service, as that would
+often be more appropriate than as a system service. The user can still be
+automatically logged in. Presumably the auto-login service can allocate the VT.
diff --git a/doc/systemd/weston.service b/doc/systemd/weston.service
new file mode 100644
index 00000000..80d242a6
--- /dev/null
+++ b/doc/systemd/weston.service
@@ -0,0 +1,66 @@
+# This is a system unit for launching Weston with auto-login as the
+# user configured here.
+#
+# Weston must be built with systemd support, and your weston.ini must load
+# the plugin systemd-notify.so.
+
+[Unit]
+Description=Weston, a Wayland compositor, as a system service
+Documentation=<a class="moz-txt-link-freetext" href="man:weston(1)">man:weston(1)</a> <a class="moz-txt-link-freetext" href="man:weston.ini(5)">man:weston.ini(5)</a>
+Documentation=<a class="moz-txt-link-freetext" href="http://wayland.freedesktop.org/">http://wayland.freedesktop.org/</a>
+
+# Make sure we are started after logins are permitted.
+After=systemd-user-sessions.service
+
+# If Plymouth is used, we want to start when it is on its way out.
+After=plymouth-quit-wait.service
+
+# D-Bus is necessary for contacting logind. Logind is required.
+Wants=dbus.socket
+After=dbus.socket
+
+# This scope is created by pam_systemd when logging in as the user.
+# This directive is a workaround to a systemd bug, where the setup of the
+# user session by PAM has some race condition, possibly leading to a failure.
+# See README for more details.
+After=session-c1.scope
+
+# Since we are part of the graphical session, make sure we are started before
+# it is complete.
+Before=graphical.target
+
+# Prevent starting on systems without virtual consoles, Weston requires one
+# for now.
+ConditionPathExists=/dev/tty0
+
+[Service]
+
+# Requires systemd-notify.so Weston plugin.
+Type=notify
+ExecStart=/usr/bin/weston
+
+# Optional watchdog setup
+TimeoutStartSec=60
+WatchdogSec=20
+
+# The user to run Weston as.
+User=westonuser
+
+# Set up a full user session for the user, required by Weston.
+PAMName=login
+
+# A virtual terminal is needed.
+TTYPath=/dev/tty7
+TTYReset=yes
+TTYVHangup=yes
+TTYVTDisallocate=yes
+
+# Fail to start if not controlling the tty.
+StandardInput=tty-fail
+
+# Log this user with utmp, letting it show up with commands 'w' and 'who'.
+UtmpIdentifier=tty7
+UtmpMode=user
+
+[install]
+WantedBy=graphical.target
</pre>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<div>
<link href="https://fonts.googleapis.com/css?family=Raleway"
rel="stylesheet" type="text/css">
<font face="Raleway, regular">
<table style="padding:20px;margin-bottom:-10px" border="0">
<tbody>
<tr>
<td style="font-size:13px; color:#ff8054; text-align:
center; padding-right:30px"> <a
href="http://www.smile.eu/"> <img
style="max-width:100%; height:auto"
src="http://ftp.smile.fr/client/Communication/signature/img/Logo-new.png"
alt="SMILE"> </a><br>
<br>
<p style="line-heigth:8px">20 rue des Jardins<br>
92600 Asnières-sur-Seine</p>
</td>
<td style="border-left: 1px solid #3b7ffe;
padding-left:20px; font-size:13px; color:#ff8054;">
<div style="color:#ff8054; font-size:14px;"> <b>Jérémy
ROSEN</b> </div>
<div style="color:#3b7ffe; font-size:13px;">
Architecte technique<br>
Responsable de l'expertise Smile-ECS </div>
<br>
<div style="color:#3b7ffe; font-size:13px;"> <span
style="white-space: nowrap"><img
style="margin-right:5px"
src="http://ftp.smile.fr/client/Communication/signature/img/mail.png"
alt="email" width="12" height="10"> <a
href="mailto:jeremy.rosen@smile.fr"
style="color:#3b7ffe; font-size:13px;
text-decoration:none;">jeremy.rosen@smile.fr</a>
</span> <br>
<span style="white-space: nowrap"><img
style="margin-right:5px"
src="http://ftp.smile.fr/client/Communication/signature/img/phone.png"
alt="phone" width="10" height="10"></span>
+33141402967 <br>
<span style="white-space: nowrap"><img
style="margin-right:5px"
src="http://ftp.smile.fr/client/Communication/signature/img/web.png"
alt="url" width="12" height="12">
<a href="http://www.smile.eu"
style="color:#3b7ffe; font-size:13px;
text-decoration:none;">http://www.smile.eu</a> </span>
</div>
<br>
<div> <span><a style="margin-right:5px"
href="https://twitter.com/GroupeSmile"><img
src="http://ftp.smile.fr/client/Communication/signature/img/rs-twitter.png"
alt="Twitter" style="max-width:100%;
height:auto"></a></span> <span><a
style="margin-right:5px"
href="https://www.facebook.com/smileopensource"><img
src="http://ftp.smile.fr/client/Communication/signature/img/rs-facebook.png"
alt="Facebook" style="max-width:100%;
height:auto"></a></span> <span><a
style="margin-right:5px"
href="https://www.linkedin.com/company/smile"><img
src="http://ftp.smile.fr/client/Communication/signature/img/rs-linkedin.png"
alt="LinkedIn" style="max-width:100%;
height:auto"></a></span> <span><a
style="margin-right:5px"
href="https://github.com/Smile-SA"><img
src="http://ftp.smile.fr/client/Communication/signature/img/rs-github.png"
alt="Github" style="max-width:100%;
height:auto"></a></span> </div>
</td>
</tr>
</tbody>
</table>
<br>
<div> <a
href="http://smile.eu/?utm_source=signature&utm_medium=email&utm_campaign=signature"><img
src="http://signature.smile.eu/assets/img/bandeau_mail_smile2017.gif.gif"
alt="Découvrez l’univers Smile, rendez-vous sur
smile.eu" border="0"></a></div>
<br>
<div style="color:#a3acb5; font-size:10px;"> <img
src="http://ftp.smile.fr/client/Communication/signature/img/eco.png"
alt="eco" width="13" height="11"> Pour la planète,
n'imprimez ce mail que si c'est nécessaire </div>
</font>
</div>
</div>
</body>
</html>