Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd doesn't actually support launch-on-demand services, need to fake it #5640

Closed
tillkamppeter opened this issue Aug 27, 2019 · 8 comments
Assignees

Comments

@tillkamppeter
Copy link

tillkamppeter commented Aug 27, 2019

I have updated the upcoming Ubuntu 19.10 to CUPS 2.2.12 and now I cannot do quick configuration changes with cupsctl any more.
When I run

$ cupsctl --share-printers

or

$ cupsctl --no-share-printers

I cannot access CUPS any more:

$ cupsctl
cupsctl: Unable to connect to server: Bad file descriptor
$ lpstat -v
lpstat: Bad file descriptor
$ 

I have to restart the daemon to get access again. At least then the configuration change gets effective:

$ sudo systemctl restart cups
$ cupsctl
_debug_logging=1
_remote_admin=0
_remote_any=0
_share_printers=0
_user_cancel_any=1
[...]

Here are my config files and error_log (in debug mode):
cupsd.conf.txt
cups-files.conf.txt
error_log.txt

@michaelrsweet michaelrsweet self-assigned this Aug 27, 2019
@michaelrsweet michaelrsweet added the investigating Investigating the issue label Aug 27, 2019
@zdohnal
Copy link
Contributor

zdohnal commented Sep 5, 2019

I can confirm this is the same issue as it is in Fedora 30+ where I built cups-2.2.12. Here are the logs from journal
cupsd_log.txt - it mostly the same log as Till has, but there are few messages from systemd itself.
It works as before after downgrade to 2.2.11.

@zdohnal
Copy link
Contributor

zdohnal commented Sep 5, 2019

This commit seems to cause it:
"The scheduler would restart continuously when idle and printers were not shared (rdar:https://52561199)"

Specifically this part:

--- a/scheduler/main.c
+++ b/scheduler/main.c
@@ -756,7 +756,10 @@ main(int argc, /* I - Number of command-line args */

#ifdef HAVE_ONDEMAND
if (OnDemand)

  •   {
    
  •     stop_scheduler = 1;
        break;
    
  •   }
    

#endif /* HAVE_ONDEMAND */

     DoingShutdown = 1;

@zdohnal
Copy link
Contributor

zdohnal commented Sep 5, 2019

It is only new assignment to stop_scheduler since 2.2.11 and setting it to 1 causes cupsd to end correctly, which breaks usage of cupsctl - cupsd ended as 'failure' before that and systemd restarted it.

@michaelrsweet
Copy link
Collaborator

Looks like a regression caused by c1a310f.

@michaelrsweet
Copy link
Collaborator

OK, so looking at the systemd documentation (ugh!) it looks like we need to return an error exit code in order for systemd to restart cupsd... There is no real support for idle exiting or minimizing the number of processes that are running... :/

@michaelrsweet michaelrsweet changed the title CUPS 2.2.12: CUPS stops working when changing configuration with cupsctl systemd doesn't actually support launch-on-demand services, need to fake it Sep 5, 2019
@michaelrsweet michaelrsweet added priority-high and removed investigating Investigating the issue labels Sep 5, 2019
@michaelrsweet michaelrsweet added this to the CUPS 2.2.x Updates milestone Sep 5, 2019
@michaelrsweet
Copy link
Collaborator

Pushed changes reverting the "stop_scheduler" change for systemd:

[master f8688d7] Add workaround for systemd's lack of true launch-on-demand support (Issue #5640)

[branch-2.2 40a54a3] Add workaround for systemd's lack of true launch-on-demand support (Issue #5640)

For all other supervisor programs supported by cupsd we can just exit with no error and the right thing happens - immediate restart if the "I need to be running" file is present, otherwise an on-demand restart if a socket connection is made. Why systemd doesn't support this pattern is baffling...

@tillkamppeter
Copy link
Author

Thank you very much, it works correctly now. I have backported the patch to Ubuntu Eoan (19.10) now.

tillkamppeter added a commit to OpenPrinting/cups-snap that referenced this issue May 16, 2020
When building CUPS with all build options at their default values
changing the CUPS configuration with the "cupsctl" command does not
work. "cupsctl" shows the configuration summary correctly when being
started without argument, but when supplying any configuration option,
cupsd.conf gets appropriately modified, but cupsd does not get started
after the change.

Such a behavior was already there, back in CUPS 2.2.12
(apple/cups#5640) and there was done a
correction on the on-demand use handling of cupsd on systems using
systemd as PID 1.

So I came to the idea to test with systemd support turned off
altogether ("./configure --disable-systemd") as inside the Snap we run
CUPS permanently and not on-demand anyway. This made cupsctl working
correctly again, restarting cupsd after applying the configuration
change. So we are going with "--disable-systemd" now.
@xuiqzy
Copy link

xuiqzy commented May 29, 2020

@michaelrsweet Sorry if I misunderstood the issue, but are you looking for a way for systemd to restart the service, even when it exits cleanly? I think there is a config option Restart=always for that, see the table here: https://www.freedesktop.org/software/systemd/man/systemd.service.html#Restart=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants