Commit Graph

3 Commits

Author SHA1 Message Date
Martin Renvoize e1e08a7f5d
Bug 40901: (QA follow-up) Keep daemon output in the traditional log files under systemd
Under koha-sysv the daemon(1) wrapper captures each daemon's stdout and
stderr to /var/log/koha/INSTANCE/NAME-output.log and NAME-error.log.
The systemd units sent that output to the journal instead, so
zebra-*.log, indexer-*.log, es-indexer-*.log, worker-*.log and
sip-error.log silently stopped being written on migrated hosts, and
log locations differed between the two init packages.

Use StandardOutput=append: and StandardError=append: on those six
units so the files are identical whichever package supervises the
daemons. The shipped logrotate stanza uses copytruncate, which is safe
with append-mode descriptors. The journal still records systemd's own
messages about each unit, which is what matters when one fails to
start, and README.Debian shows the drop-in for sites that prefer the
journal. Plack and the Z39.50 responder already wrote their own files.

The README, NEWS.Debian entry and koha-common(8) text that described
the journal-only behaviour are updated accordingly.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-09-29 09:02:39 +00:00
Martin Renvoize 0aa04d9ddc
Bug 40901: (QA follow-up) Document the two init packages, the new options and the logging change
- koha-systemd.README.Debian was written for the first prototype: it
  named koha-worker-long@.service (now koha-worker-long_tasks@), said
  SIP needs the sip.enabled flag file (no longer read on systemd hosts),
  described coexisting with koha-common and a manual migration that the
  postinst now performs. Rewrite it to describe the actual units, how
  the koha-* helpers map onto them, where each configuration value is
  read from, how to relax the sandboxing with a drop-in, and the
  migration.
- Logging is the one visible behavioural change and was undocumented:
  with koha-sysv the daemon(1) wrapper captured stdout/stderr to
  /var/log/koha/INSTANCE/NAME-output.log and NAME-error.log; with
  koha-systemd that output is in the journal, so zebra-*, indexer-*,
  es-indexer-*, worker-* and sip-error.log are no longer written, while
  everything Koha writes itself (Starman's plack.log/plack-error.log,
  the log4perl files, z3950.log, the Apache vhost logs) is unchanged.
  Spell that out in README.Debian, in a new koha-systemd NEWS.Debian
  entry shown by apt-listchanges on upgrade, and in a "Service
  management" section of the koha-common(8) man page.
- Add --enable/--disable to the koha-zebra, koha-worker, koha-indexer
  and koha-es-indexer man pages.
- z3950_responder.pl's synopsis listed --config-dir twice and had lost
  -c, which is still a YAZ pass-through option; put -c back.
- t/00-valid-systemd-units.t: give it the usual shebang, and ignore
  every "Command ... is not executable" line from systemd-analyze rather
  than only the ones for scripts in this repository. Whether starman or
  /usr/share/koha/bin/... is installed on the host running the test says
  nothing about the unit files, and the old filter made the test fail on
  any development machine without the Koha packages.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-09-29 09:02:38 +00:00
Tomás Cohen Arazi dc8cced6be
Bug 40901: Add koha-systemd package with native systemd units
This patch introduces the koha-systemd package, which provides native
systemd service units for managing Koha instances. Each service type
(Plack, Zebra, SIP, Z3950, workers, indexers) is managed as a separate
systemd unit using instance templates.

The package includes:
- 8 service templates (plack, zebra, sip, z3950, worker, worker-long,
  indexer, es-indexer)
- 2 target units (koha@.target for per-instance, koha.target for global)
- Helper script (koha-systemd-ctl) for managing services

All service units include:
- KOHA_HOME environment variable pointing to /usr/share/koha
- WorkingDirectory set to /var/lib/koha/%i
- Proper user/group permissions (%i-koha)

This allows granular control over individual services per instance and
leverages systemd features like dependency management, resource limits,
and journald logging.

Test plan:
1. Build and install the package
2. Enable services for an instance
3. Verify all services start correctly
4. Check journalctl logs show no errors

Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-09-29 09:01:21 +00:00