I have an issue with an init/systemd service that causes the system to
hang on shutdown. I never had to meddle with system services so far, so
maybe someone more experienced could help me out here?
So here’s the issue: I recently had to make a Canon LBP2900 printer work
on a Leap 42.1 workstation. The printer comes with Canon’s proprietary
CAPT driver and daemon (ccpd). The daemon, configured as a service,
starts up and works without a hitch. However, somehow the system fails
to end it when shutting down. I am getting three flashing red asterisks
and the console output “ccpd stop-service running” and then everything
hangs. Executing “service ccpd stop” as root manually works. I also
remember the same setup working fine before on an older OpenSuse system.
Thanks in advance for any directions you could point me to…
I’m attaching my /etc/init.d/ccpd for reference:
#!/bin/sh
# startup script for Canon Printer Daemon for CUPS (ccpd)
if `ps awx | grep cupsd | grep -v grep | wc -l` -eq 0 ]; then
while `ps awx | grep cupsd | grep -v grep | wc -l` -eq 0 ]
do
sleep 3
done
sleep 5
fi
if -f /etc/rc.d/init.d/functions ]; then
if -f /etc/slackware-version ]; then
SYS_F="SL"
else
. /etc/rc.d/init.d/functions
SYS_F="RH"
fi
elif -x /sbin/startproc ]; then
SYS_F="Su"
elif -x /sbin/start-stop-daemon ]; then
SYS_F="De"
fi
DAEMON=/usr/sbin/ccpd
LOCKFILE=/var/lock/subsys/ccpd
export PATH=$PATH:/usr/local/sbin:/usr/local/bin
ccpd_start ()
{
echo -n "Starting ${DAEMON}: "
if "$SYS_F" = "RH" ]; then
daemon ${DAEMON}
"$?" = "0" ] && touch ${LOCKFILE}
echo "."
elif "$SYS_F" = "Su" ]; then
startproc ${DAEMON}
echo "."
elif "$SYS_F" = "De" ]; then
start-stop-daemon --start --quiet --oknodo --exec ${DAEMON}
echo "."
else
`${DAEMON}`
fi
}
ccpd_stop ()
{
echo -n "Shutting down ${DAEMON}: "
if "$SYS_F" = "De" ]; then
start-stop-daemon --stop --quiet --oknodo --signal 15 --exec ${DAEMON}
echo "."
elif "$SYS_F" = "SL" ]; then
kill -KILL `pidof ${DAEMON}`
"$?" = "0" ] && rm -f ${LOCKFILE}
echo
else
killproc ${DAEMON}
"$?" = "0" ] && rm -f ${LOCKFILE}
echo
fi
}
case $1 in
start)
ccpd_start
;;
stop)
ccpd_stop
;;
status)
echo "${DAEMON}:" `pidof ${DAEMON}`
;;
restart)
ccpd_stop
ccpd_start
;;
*)
echo "Usage: ccpd {start|stop|status}"
exit 1
;;
esac
exit 0
Thank you malcolmlewis for the welcoming and for pointing out that thread. Sorry everybody for getting back so late to that thread, but the problem persists.
I have in fact no issue with getting the ccpd service to run (as dealt with in the aforementioned thread) or making the printer do its job. In fact after enabling it (via service, systemctl or yast) the ccpd daemon loads and works just fine - until I am trying to shutdown the system. Then the system hangs at the shutdown (plymouth) splash or, when disabled, at an empty console without accepting any input aside from the SysRq-key.
I can stop (and restart) the process manually via Yast, “systemctl stop ccpd.service” or “service ccpd stop”.
If I do not do that before calling the shutdown command, everything hangs, which is pretty annoying, since I’d rather not think of my printer after a day’s work. I’d guess that for whatever reason ccpd gets the system entangled in a loop on shutdown that impedes completing it. But how might I go about troubleshooting that?
I’d start with investigating how your Canon Daemon script is initiated. The commands you have posted are init commands which by themselves would be subject to all the legacy issues relating to shutdown (SysVinit has well known problems with orphaned processes which make orderly shutdowns problematic). You say you verified some systemd command exists, but don’t actually post it.
Run something like the following (A guess for how such a systemd Unit file might be named)
systemctl status ccpd
If you inspect and perhaps post the results of the above command, it would reveal if a Unit file exists or if a virtual Unit file was run to enable support for the init script, what options exist, environ variables, etc.
Although it’s significant that the service should be managed with a systemd Unit file, you may still have issues with how the script actually runs. Since SysVinit can’t be sure when nothing is pending there might be some timeout enabled which would have to be addressed.
Maybe if you inspected the Unit file (if exists), you can implement an ExecStop which actually kills/terminates the process.
Of course, if implemented incorrectly you might kill a print job which hasn’t completed or is otherwise pending (in queue?).
Some additional information: It looks like ccpd does not terminate gracefully even when stopped manually. I am getting the following output after calling systemctl to stop ccpd.service from the command line. I would be fine if the process were to be killed the same way on shutdown - but why doesn’t that happen?
Thank your very much for the hints, now I have something that I can look into / try out. As I said, I have never had anything to do with neither sysvinit nor systemd, so this is all pretty new territory for me.
Every forking service must specify PIDFile so systemd can know when service is started (or at least when service declares that it is started). Otherwise systemd attempts to guess what is the main service process and it may guess wrong. If ccpd does not maintain PID file itself, either you need to consider other service types or create wrapper to do it. Using initscript as the first approximation is common method.
Thank you everybody. I will investigate this further when I have time. For now I have found a workaround by automatically starting and stopping the service at user logon and logoff respectively, since this is a desktop system only. It really is a shame that Canon does not release more up to date drivers or that it would not simply follow the standard cups driver model.
Missed this one so far. I’ve had some serious professional issues with Canon printers on linux networks. What I generally do, is install the driver package, but use Yast’s printer module to find the appropriate ppd file for the printer. This has by far given me the best results.
Yes, but this is not about the printer ppd configuration per se. It specifically relates to the OP wishing to have the underlying proprietary Canon daemon stop cleanly at shutdown.