[systemd-devel] Can a systemd --user instance rely on After= of systemd --system instance?

Kai Krakow hurikhan77 at gmail.com
Mon Mar 6 19:31:06 UTC 2017


Am Sat, 4 Mar 2017 22:07:57 +0300
schrieb Andrei Borzenkov <arvidjaar at gmail.com>:

> 04.03.2017 13:49, Peter Hoeg пишет:
> > Hi,
> >   
> >> If I have a user service which needs to have the system database
> >> server available: How do I construct a proper depend?  
> > 
> > As Lennart was pointing out, the user and system instances do not
> > know anything about each other, so you cannot.
> >   
> 
> "You cannot because it is currently unimplemented", "you cannot
> because we do not care but feel free to implement" or "you cannot
> because we will never even consider it"?
> 
> > The 2 other options I can think of:
> > 
> > a) Run a system service specifying your user id in User=
> >   
> 
> The problem has nothing to do with ownership so it won't help.

I'm running it in the user context for different reasons. I don't think
that setting the UID is the same. Additionally, I want users to be able
to restart their services during deployments.

> > b) Enable socket activation (if possible) on the system instance
> > database. That way your user instance will simply wait on the socket
> > until the server comes up.
> >   
> 
> This means you need to set absurdly large TimeoutStart because you
> have no idea when other service appears, so every time you attempt to
> start service you will need to wait absurdly large time before
> proceeding with error handling. Proper service dependency won't even
> attempt to start dependent service until dependencies are known to
> run.

Yes, and setting such TimeoutStart values is not meant to be the fix,
I'm sure. The database service here takes 2-3 minutes to fully start
and be ready. This is due to high IO load during startup but also due
to fully checking the database from the service ExecPost.

> systemd already propagates some unit types (devices, mounts and swaps)
> from system to user instance. Are there any fundamental problems that
> prevent doing it for other types?

I'd imagine something like Requires=system/mysqld.service to prefix the
dependency to the system instance.


-- 
Regards,
Kai

Replies to list-only preferred.




More information about the systemd-devel mailing list