apple / cups

Apple CUPS Sources
https://www.cups.org
Apache License 2.0
1.95k stars 464 forks source link

cupsd quietly dies #4936

Closed isgroup-srl closed 7 years ago

isgroup-srl commented 7 years ago

TLTR; Just installed a new print server and cupsd dies with no logged errors :\

LONG; Ubuntu 16.04.1 LTS, fresh install plus:

Configuration seems fine:

cupsd -t

"/etc/cups/cups-files.conf" is OK. "/etc/cups/cupsd.conf" is OK.

Printing too, no issues in log files AFAIK but the process disappear after overnight. I attached a strace to figure out and it revealed.. nothing ^_^

# strace -ff of the cupsd process
unlink("/etc/cups/printers.conf.O")     = 0
rename("/etc/cups/printers.conf", "/etc/cups/printers.conf.O") = 0
rename("/etc/cups/printers.conf.N", "/etc/cups/printers.conf") = 0
open("/var/cache/cups/job.cache.N", O_WRONLY) = -1 ENOENT (No such file or directory)
open("/var/cache/cups/job.cache.N", O_WRONLY|O_CREAT|O_EXCL, 0666) = 13
fstat(13, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
lstat("/var/cache/cups/job.cache.N", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
ftruncate(13, 0)                        = 0
fcntl(13, F_GETFD)                      = 0
fcntl(13, F_SETFD, FD_CLOEXEC)          = 0
getuid()                                = 0
getuid()                                = 0
fchown(13, 0, 7)                        = 0
fchmod(13, 0640)                        = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2692, ...}) = 0
write(13, "# Job cache file for CUPS v2.1.3"..., 4096) = 4096
write(13, "</Job>\n<Job 27>\nState 9\nCreated "..., 4094) = 4094
write(13, "Created 1481125685\nCompleted 148"..., 4081) = 4081
write(13, "Created 1481759020\nCompleted 148"..., 3321) = 3321
fsync(13)                               = 0
close(13)                               = 0
unlink("/var/cache/cups/job.cache.O")   = 0
rename("/var/cache/cups/job.cache", "/var/cache/cups/job.cache.O") = 0
rename("/var/cache/cups/job.cache.N", "/var/cache/cups/job.cache") = 0
epoll_wait(5, 0x55bebd9b2de0, 4096, 86371000) = -1 EINTR (Interrupted system call)
--- SIGTERM {si_signo=SIGTERM, si_code=SI_USER, si_pid=1, si_uid=0} ---
--- SIGCONT {si_signo=SIGCONT, si_code=SI_USER, si_pid=1, si_uid=0} ---
rt_sigreturn({mask=[]})                 = -1 EINTR (Interrupted system call)
epoll_ctl(5, EPOLL_CTL_DEL, 10, 0x7ffdb95ea2f0) = 0
epoll_ctl(5, EPOLL_CTL_DEL, 3, 0x7ffdb95ea2f0) = 0
close(10)                               = 0
unlink("/var/run/cups/certs/0")         = 0
epoll_ctl(5, EPOLL_CTL_DEL, 11, 0x7ffdb95ea320) = 0
close(11)                               = 0
close(12)                               = 0
close(6)                                = 0
close(7)                                = 0
close(8)                                = 0
open("/var/cache/cups/org.cups.cupsd", O_RDONLY|O_CREAT|O_EXCL, 0400) = -1 EEXIST (File exists)
rt_sigprocmask(SIG_BLOCK, [TERM CHLD], [], 8) = 0
open("/var/cache/cups/job.cache.N", O_WRONLY) = -1 ENOENT (No such file or directory)
open("/var/cache/cups/job.cache.N", O_WRONLY|O_CREAT|O_EXCL, 0666) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
lstat("/var/cache/cups/job.cache.N", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
ftruncate(6, 0)                         = 0
fcntl(6, F_GETFD)                       = 0
fcntl(6, F_SETFD, FD_CLOEXEC)           = 0
getuid()                                = 0
getuid()                                = 0
fchown(6, 0, 7)                         = 0
fchmod(6, 0640)                         = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2692, ...}) = 0
write(6, "# Job cache file for CUPS v2.1.3"..., 4096) = 4096
write(6, "</Job>\n<Job 27>\nState 9\nCreated "..., 4094) = 4094
write(6, "Created 1481125685\nCompleted 148"..., 4081) = 4081
write(6, "Created 1481759020\nCompleted 148"..., 3321) = 3321
fsync(6)                                = 0
close(6)                                = 0
unlink("/var/cache/cups/job.cache.O")   = 0
rename("/var/cache/cups/job.cache", "/var/cache/cups/job.cache.O") = 0
rename("/var/cache/cups/job.cache.N", "/var/cache/cups/job.cache") = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
close(5)                                = 0
unlink("/var/run/cups/cupsd.pid")       = 0
exit_group(0)                           = ?
+++ exited with 0 +++

A simple service cups restart bring back to life the daemon, pretty annoying for a print server.

michaelrsweet commented 7 years ago

OK, what you have provided so far shows that cupsd is idle exiting, as designed.

If you want to keep cupsd running all the time, do one of the following:

  1. Enable the web interface
  2. Enable printer sharing for one or more printers

(a pending job will also keep cupsd running)

isgroup-srl commented 7 years ago

Thanks @michaelrsweet for the answer!

The web interface is running on port 631 as usual and the printer is shared.

(server)$ lpstat -t
scheduler is running
no system default destination
device for ricoh: socket://print:9100
ricoh accepting requests since Mon 19 Dec 2016 06:56:37 PM CET
printer ricoh is idle.  enabled since Mon 19 Dec 2016 06:56:37 PM CET

Also by modifying the printer I see the Sharing: Share This Printer already ticked. As further confirmation we already configured the printer on our clients and sent some jobs to it that printed successfully.

(client)$ lpstat -t
scheduler is running
system default destination: ricoh
device for QL-570: usb://Brother/QL-570?serial=M3Z198620
device for ricoh: ipp://print:631/printers/ricoh
[...]
printer ricoh is idle.  enabled since Mon 19 Dec 2016 06:56:36 PM CET

Should I set the printer as system default on the server? Would it help?

isgroup-srl commented 7 years ago

Testing the system with a default printer, maybe it helps. Before:

(server)$ lpstat -t
scheduler is running
no system default destination
device for ricoh: socket://print:9100
ricoh accepting requests since Mon 19 Dec 2016 06:56:37 PM CET
printer ricoh is idle.  enabled since Mon 19 Dec 2016 06:56:37 PM CET

After:

(server)$ lpstat -t
scheduler is running
system default destination: ricoh
device for ricoh: socket://print:9100
ricoh accepting requests since Mon 19 Dec 2016 06:56:37 PM CET
printer ricoh is idle.  enabled since Mon 19 Dec 2016 06:56:37 PM CET
isgroup-srl commented 7 years ago

Also noticed that under System Settings the setting Share printers connected to this system is unticked, still the ricoh is shared and works. Should Share printers connected to this system be on to disable idle timeout?

Not doing this for now to test if setting a system default printer fix the issue.

isgroup-srl commented 7 years ago

Cups daemon exited again, now trying with Share printers connected to this system in Server Settings.

michaelrsweet commented 7 years ago

In addition to sharing the printer, you need to enable printer sharing on the system (from the main admin tab), otherwise cupsd will idle exit.

isgroup-srl commented 7 years ago

Thanks @michaelrsweet testing this config and will report back. Feeling like a regression test script ^_^

isgroup-srl commented 7 years ago

@michaelrsweet I can confirm that the only setting who prevents cups going idle and exiting is Share printers connected to this system in Server Settings. Thanks!