Bug 33371 - Add 'koha-common.service' systemd service
Summary: Add 'koha-common.service' systemd service
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Packaging (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Mason James
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-30 14:25 UTC by Mason James
Modified: 2023-12-28 20:47 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.11.00,23.05.00,22.11.07


Attachments
Bug 33371: Add 'koha-common.service' systemd service (1.61 KB, patch)
2023-04-01 11:33 UTC, Mason James
Details | Diff | Splinter Review
Bug 33371: Add 'koha-common.service' systemd service (1.66 KB, patch)
2023-05-19 12:17 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 33371: Add [Install] section to koha-common.service (805 bytes, patch)
2023-06-01 12:55 UTC, Mason James
Details | Diff | Splinter Review
Bug 33371: Add [Install] section to koha-common.service (1.26 KB, patch)
2023-06-01 13:08 UTC, Mason James
Details | Diff | Splinter Review
[PATCH] Bug 33371: Add [Install] section to koha-common.service (1.31 KB, patch)
2023-06-01 13:30 UTC, Andrii Nugged
Details | Diff | Splinter Review
Bug 33371: Add [Install] section to koha-common.service (1.30 KB, patch)
2023-06-01 13:32 UTC, Andrii Nugged
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Mason James 2023-03-30 14:25:23 UTC
this bug tracks the progress of adding 'koha-common.service' as a systemd service
Comment 1 Mason James 2023-04-01 11:33:41 UTC
Created attachment 149060 [details] [review]
Bug 33371: Add 'koha-common.service' systemd service

to test

- install current package
- note following $message on install
 'Failed to enable unit: Unit /run/systemd/generator.late/koha-common.service is transient or generated.'

- apply patch, build package, install new package
- note $message is gone! :)

- test koha-common.service
   # systemctl start  koha-common
   # systemctl status koha-common | grep running
     Active: active (running) since Sun 2023-04-02 00:27:31 NZDT <<<

   # systemctl stop  koha-common

   # systemctl status koha-common | grep dead
     Active: inactive (dead) since Sun 2023-04-02 00:25:34 NZDT <<<
Comment 2 Tomás Cohen Arazi 2023-05-19 12:17:36 UTC
Created attachment 151474 [details] [review]
Bug 33371: Add 'koha-common.service' systemd service

to test

- install current package
- note following $message on install
 'Failed to enable unit: Unit /run/systemd/generator.late/koha-common.service is transient or generated.'

- apply patch, build package, install new package
- note $message is gone! :)

- test koha-common.service
   # systemctl start  koha-common
   # systemctl status koha-common | grep running
     Active: active (running) since Sun 2023-04-02 00:27:31 NZDT <<<

   # systemctl stop  koha-common

   # systemctl status koha-common | grep dead
     Active: inactive (dead) since Sun 2023-04-02 00:25:34 NZDT <<<

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 3 Tomás Cohen Arazi 2023-05-19 12:21:15 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 4 David Cook 2023-05-22 00:56:29 UTC
I don't know about this one...

It feels hacky and yet it should work. 

On one hand, it would be nice to convert from the SysV init script to a Systemd unit.

On the other hand, Systemd doesn't work well for containers. 

Maybe we should have a script or scripts that are called by either the SysV init, Systemd, or whatever management program we choose. That's for the future though I think...
Comment 5 Andrii Nugged 2023-06-01 02:20:17 UTC
PROBLEM! On my Ubuntu 20.04 LTS it doesnt comes up after REBOOT (!!!).
So I need manually run "service koha-common start".

AFTER REBOOT:

#> service koha-common status
● koha-common.service - Start required services for each Koha instance
     Loaded: loaded (/etc/init.d/koha-common; enabled; vendor preset: enabled)
     Active: inactive (dead)



I found that on my server koha-common.service lacks for

[Install]
WantedBy=multi-user.target

without this, it dies:

#> systemctl enable koha-common
```
Synchronizing state of koha-common.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable koha-common
The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.
```


and with "Install" block it now ok:

#> systemctl enable koha-common
```
Synchronizing state of koha-common.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable koha-common
Created symlink /etc/systemd/system/multi-user.target.wants/koha-common.service → /lib/systemd/system/koha-common.service.
```



And on reboot now I have it ALIVE!


#> service koha-common status
● koha-common.service - Start required services for each Koha instance
     Loaded: loaded (/etc/init.d/koha-common; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-06-01 05:15:09 EEST; 14s ago
Comment 7 Mason James 2023-06-01 13:08:46 UTC
Created attachment 151927 [details] [review]
Bug 33371: Add [Install] section to koha-common.service

to test:

 1/ install pkg, reboot, note service is not 'active'

 2/ add patch, build package

 3/ install pkg, reboot, note service is 'active' :)

  root@deb11:/etc# systemctl status koha-common
  * koha-common.service - Start required services for each Koha instance
     Loaded: loaded (/etc/init.d/koha-common; enabled; vendor preset: enabled) <<<<
     Active: active (exited) since Thu 2023-06-01 12:45:08 UTC; 13min ago
      Tasks: 0 (limit: 2244)
     Memory: 0B
        CPU: 0
     CGroup: /system.slice/koha-common.service
  Jun 01 12:45:08 deb11 systemd[1]: Starting Start required services for each Koha instance...
Comment 8 Andrii Nugged 2023-06-01 13:30:37 UTC Comment hidden (obsolete)
Comment 9 Andrii Nugged 2023-06-01 13:32:02 UTC
Created attachment 151930 [details] [review]
Bug 33371: Add [Install] section to koha-common.service

to test:

 1/ install pkg, reboot, note service is not 'active'

 2/ add patch, build package

 3/ install pkg, reboot, note service is 'active' :)

  root@deb11:/etc# systemctl status koha-common
  * koha-common.service - Start required services for each Koha instance
     Loaded: loaded (/etc/init.d/koha-common; enabled; vendor preset: enabled) <<<<
     Active: active (exited) since Thu 2023-06-01 12:45:08 UTC; 13min ago
      Tasks: 0 (limit: 2244)
     Memory: 0B
        CPU: 0
     CGroup: /system.slice/koha-common.service
  Jun 01 12:45:08 deb11 systemd[1]: Starting Start required services for each Koha instance...

Signed-off-by: Andrew Nugged <nugged@gmail.com>
Comment 10 Tomás Cohen Arazi 2023-06-01 14:55:04 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 11 Matt Blenkinsop 2023-06-08 17:00:13 UTC
Nice work everyone!

Pushed to stable for 22.11.x