From e96e96b4bd0d4e6f634bbb66b95d6e475501541c Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Wed, 25 Nov 2020 08:12:32 +0100 Subject: [PATCH] [Fedora] cups.service.in: Use 'notify' service type and run after network.target 1) If the service is defined with 'simple' type, the result of 'systemctl' is 0 regardless of actual startup result, because it reports success/failure of forking process (even before cupsd is started). This way errors due bad configuration or programming errors are masked during systemctl invocation. The 'notify' type depends on executable sending a 'Im running' type of message to systemd after successful start and systemctl's return code depends whether this message came or not, which solves the issue. 2) The service needs to be started after all units needed for network.target are activated. This prevents starting cupsd before we have ports ready. Fedora bugs: https://bugzilla.redhat.com/show_bug.cgi?id=1153660 (adding network.target) https://bugzilla.redhat.com/show_bug.cgi?id=1088918 (change of the service type) --- scheduler/cups.service.in | 4 ++-- scheduler/main.c | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/scheduler/cups.service.in b/scheduler/cups.service.in index 79d2c403e8..9609d8ee7f 100644 --- a/scheduler/cups.service.in +++ b/scheduler/cups.service.in @@ -1,12 +1,12 @@ [Unit] Description=CUPS Scheduler Documentation=man:cupsd(8) -After=sssd.service +After=network.target sssd.service Requires=cups.socket [Service] ExecStart=@sbindir@/cupsd -l -Type=simple +Type=notify Restart=on-failure [Install] diff --git a/scheduler/main.c b/scheduler/main.c index d5fdf971a8..42995eac21 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -681,8 +681,16 @@ main(int argc, /* I - Number of command-line args */ #ifdef HAVE_ONDEMAND if (OnDemand) + { cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED, NULL, NULL, "Scheduler started on demand."); - else +# ifdef HAVE_SYSTEMD + sd_notifyf(0, "READY=1\n" + "STATUS=Scheduler is running...\n" + "MAINPID=%lu", + (unsigned long) getpid()); +# endif /* HAVE_SYSTEMD */ + } else + #endif /* HAVE_ONDEMAND */ if (fg) cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED, NULL, NULL, "Scheduler started in foreground."); -- 2.47.2