Commit Graph

5 Commits

Author SHA1 Message Date
Martin Renvoize 3fb9421561
Bug 40901: (QA follow-up) Make koha-common.service a dependency-free shim
The compat unit declared BindsTo=koha.target and After=koha.target while
its ExecStop ran "systemctl stop koha.target". After= orders this unit's
stop before the target's, so the ExecStop waited on a job that could not
run until the ExecStop itself finished. Every "systemctl stop koha-common"
and every "systemctl restart koha-common" hung for TimeoutStopSec (90s
by default) and left the unit in failed state. An async --no-block stop
does not help either: the queued target stop replaces the start job the
restart transaction needs, and everything ends up stopped.

Drop the dependencies. The unit is now a plain oneshot with
RemainAfterExit that starts koha.target in ExecStart and stops it in
ExecStop, which is all the old "service koha-common" UX requires.
Verified with a replica set of user units: start, stop and restart of
the shim each complete in well under a second, restart gives every
service a new PID, and managing koha.target directly is unaffected.
The one cosmetic consequence is that the shim stays "active (exited)"
if koha.target is stopped behind its back; README.Debian says to look
at koha.target for real status.

Also sets SyslogIdentifier so its journal lines are identifiable.

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:30 +00:00
Martin Renvoize 9485938333
Bug 40901: (QA follow-up) Keep /etc conffiles under their koha-common names
The cron, logrotate and defaults files were renamed from koha-common.*
to koha-core.*, so debhelper installed them as /etc/cron.d/koha-core,
/etc/logrotate.d/koha-core and /etc/default/koha-core. dpkg never
deletes a conffile that a package stops shipping, so after an upgrade
both the old and the new files exist side by side:

- every cron job (process_message_queue.pl every 15 minutes,
  overdue_notices.pl, fines.pl, backups...) runs twice
- logrotate complains about duplicate log entries every night
- the admin's /etc/default/koha-common (USE_INDEXER_DAEMON,
  INDEXER_PARAMS, ES_* tuning) is replaced by a symlink to a fresh
  copy of the packaged defaults, silently losing every customisation

Keep the on-disk names instead: koha-core now ships the files as
debian/koha-core.koha-common.* and debian/rules passes
--name=koha-common to dh_installinit, dh_installcron and
dh_installlogrotate. Because koha-core Replaces the old koha-common,
dpkg hands each conffile over with the admin's content intact and no
duplicates are left behind. The defaults file content is byte-identical
to the old koha-common.default so nobody gets a spurious conffile
prompt, and koha-generate-env reads the single canonical name again.

The experimental pre-split koha-core (used by koha-full) had its own
/etc/default/koha-core and /etc/init.d/koha-core; a new
koha-core.maintscript migrates the former with mv_conffile and removes
the latter, with the matching rc.d links dropped in the postinst.
/etc/koha/koha-worker@.service, whose template was deleted, is removed
from upgrading systems too. koha-core.preinst gains the #DEBHELPER#
token the maintscript machinery needs.

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:24 +00:00
Martin Renvoize 868947cb55
Bug 40901: (QA follow-up) Quote path/option values in koha-generate-env env files
systemd EnvironmentFile parsing treats unquoted values as ending at the
first whitespace.  PLACK_PSGIFILE and Z3950_CONFIGDIR are paths that
could in principle contain spaces; Z3950_ADDITIONAL_OPTS routinely holds
multiple flags separated by spaces (e.g. "--port 9999 --verbose").

Wrap these three values in double-quotes in the generated env file so
systemd reads the full value even when it contains spaces.

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:04 +00:00
Martin Renvoize 3644a8407f
Bug 40901: (QA follow-up) Fix stale /etc/default/koha-common reference in koha-generate-env
koha-generate-env sourced /etc/default/koha-common to read
INDEXER_TIMEOUT, but the defaults file was renamed to
/etc/default/koha-core in this patchset.  On fresh installations no
/etc/default/koha-common exists, so INDEXER_TIMEOUT was always silently
fixed at the built-in default of 5, ignoring any admin customisation.

Read /etc/default/koha-core first; fall back to /etc/default/koha-common
so that systems upgrading from the pre-split packaging still pick up
their existing settings.

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:00 +00:00
Tomás Cohen Arazi bf8529fbd4
Bug 40901: (follow-up) Read service config from koha-conf.xml in systemd units
The systemd units were missing most of the parameters that the SysV
init functions read from koha-conf.xml. This caused wrong worker
counts, missing log files, ignored batch sizes, and other config
being silently dropped.

This patch adds koha-generate-env, a helper script that reads
koha-conf.xml and writes an EnvironmentFile for each service.
Each unit runs it as ExecStartPre and then uses the variables.

Changes per unit:
- koha-plack@: workers, max-requests, access/error logs,
  environment (development/deployment), per-instance psgi, -M FindBin
- koha-zebra@: loglevels, max_record_size, timestamp format
- koha-es-indexer@: batch_size
- koha-indexer@: INDEXER_TIMEOUT from /etc/default/koha-common
- koha-z3950@: config dir fallback to global, additional options

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:42 +00:00