diff --git a/debian/systemd/koha-common.service b/debian/systemd/koha-common.service index 5387ee3ae5..57aacd5204 100644 --- a/debian/systemd/koha-common.service +++ b/debian/systemd/koha-common.service @@ -7,7 +7,9 @@ After=koha.target [Service] Type=oneshot RemainAfterExit=yes -ExecStartPre=+/bin/sh -c 'for i in $(koha-list --enabled --elasticsearch 2>/dev/null); do systemctl enable --now "koha-es-indexer@$i.service" 2>/dev/null || true; done' +# Instances can switch to Elasticsearch after their units were enabled, so +# re-discover ES indexers on every start, like the SysV init script did. +ExecStartPre=-/usr/sbin/koha-systemd-ctl sync-es-indexers ExecStart=/bin/true ExecStop=/bin/systemctl stop koha.target diff --git a/debian/systemd/koha-systemd-ctl b/debian/systemd/koha-systemd-ctl index ebd6b30a85..b75c3a4f4c 100755 --- a/debian/systemd/koha-systemd-ctl +++ b/debian/systemd/koha-systemd-ctl @@ -22,6 +22,9 @@ Commands: restart Restart specific service for instance status Show status of specific service for instance + sync-es-indexers Enable and start the ES indexer for every + instance configured to use Elasticsearch + Services: plack, zebra, sip, z3950, worker, worker-long_tasks, indexer, es-indexer Examples: @@ -33,6 +36,17 @@ EOF exit 1 } +if [ "${1:-}" = "sync-es-indexers" ]; then + # Which search engine an instance uses is plain koha-conf.xml state, so + # switching an instance to Elasticsearch never runs 'systemctl enable'. + # Re-discover ES instances here, like the SysV init script did on every + # start. + for instance in $(koha-list --enabled --elasticsearch 2>/dev/null); do + systemctl enable --now "koha-es-indexer@${instance}.service" || true + done + exit 0 +fi + [ $# -lt 2 ] && usage CMD=$1