Replace some koha-* scripts that use "daemon" with systemd unit files
Hi all, What do people think about replacing some of the koha-* script files with systemd unit files? I'm creating a service for a RabbitMQ-based task scheduler and my unit file is 17 declarative configuration lines. Creating a koha-mq-scheduler file looks like it'll be hundreds of lines of shell script code. My unit file is actually a "template" file, which means I have 1 file in /etc/systemd/system/koha-mq-scheduler@.service and I can just invoke "systemctl start koha-mq-scheduler@INSTANCE.service" to start the service. You can use the %i placeholder in the unit file and it will be replaced with INSTANCE, so you can set paths, environmental variables, et cetera very easily. It's so easy and convenient. I think all modern Linux OSes use systemd for their init system, so I think it would be pretty safe to use. I'm happy to work on this one, but I guess I'd like to see if other people have interest in this. David Cook Systems Librarian Prosentient Systems 72/330 Wattle St Ultimo, NSW 2007 Australia Office: 02 9212 0899 Online: 02 8005 0595
Yeah, and contribute that task schedule in the meantime El mié., 3 de junio de 2020 23:31, <dcook@prosentient.com.au> escribió:
Hi all,
What do people think about replacing some of the koha-* script files with systemd unit files?
I’m creating a service for a RabbitMQ-based task scheduler and my unit file is 17 declarative configuration lines. Creating a koha-mq-scheduler file looks like it’ll be hundreds of lines of shell script code.
My unit file is actually a “template” file, which means I have 1 file in /etc/systemd/system/koha-mq-scheduler@.service and I can just invoke “systemctl start koha-mq-scheduler@INSTANCE.service” to start the service. You can use the %i placeholder in the unit file and it will be replaced with INSTANCE, so you can set paths, environmental variables, et cetera very easily. It’s so easy and convenient.
I think all modern Linux OSes use systemd for their init system, so I think it would be pretty safe to use.
I’m happy to work on this one, but I guess I’d like to see if other people have interest in this.
David Cook
Systems Librarian
Prosentient Systems
72/330 Wattle St
Ultimo, NSW 2007
Australia
Office: 02 9212 0899
Online: 02 8005 0595
_______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
Unfortunately, I was exaggerating, when I said “task scheduler”. What I really have right now is just a FIFO worker that handles a long-running task for a custom local tool. I want to start small and build up, rather than trying to design something that will meet every use case. But I have contributed my thoughts to https://bugs.koha-community.org/bugzilla3//show_bug.cgi?id=22417 <https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22417> . And actually I would really like to collaborate with you, Tomas, on creating functionality that would make Koha Plugins first class citizens for background tasks, as I think that will actually help us focus on the message queue and task scheduling systems rather than the tasks themselves. David Cook Systems Librarian Prosentient Systems 72/330 Wattle St Ultimo, NSW 2007 Australia Office: 02 9212 0899 Online: 02 8005 0595 From: Tomas Cohen Arazi <tomascohen@gmail.com> Sent: Thursday, 4 June 2020 12:44 PM To: David Cook <dcook@prosentient.com.au> Cc: Koha Devel <koha-devel@lists.koha-community.org>; Victor Grousset <victor.grousset@biblibre.com> Subject: Re: [Koha-devel] Replace some koha-* scripts that use "daemon" with systemd unit files Yeah, and contribute that task schedule in the meantime El mié., 3 de junio de 2020 23:31, <dcook@prosentient.com.au <mailto:dcook@prosentient.com.au> > escribió: Hi all, What do people think about replacing some of the koha-* script files with systemd unit files? I’m creating a service for a RabbitMQ-based task scheduler and my unit file is 17 declarative configuration lines. Creating a koha-mq-scheduler file looks like it’ll be hundreds of lines of shell script code. My unit file is actually a “template” file, which means I have 1 file in /etc/systemd/system/koha-mq-scheduler@.service <mailto:/etc/systemd/system/koha-mq-scheduler@.service> and I can just invoke “systemctl start koha-mq-scheduler@INSTANCE.service <mailto:koha-mq-scheduler@INSTANCE.service> ” to start the service. You can use the %i placeholder in the unit file and it will be replaced with INSTANCE, so you can set paths, environmental variables, et cetera very easily. It’s so easy and convenient. I think all modern Linux OSes use systemd for their init system, so I think it would be pretty safe to use. I’m happy to work on this one, but I guess I’d like to see if other people have interest in this. David Cook Systems Librarian Prosentient Systems 72/330 Wattle St Ultimo, NSW 2007 Australia Office: 02 9212 0899 Online: 02 8005 0595 _______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org <mailto:Koha-devel@lists.koha-community.org> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
I've got a local package installing a systemd template unit file at /etc/systemd/system/koha-mq-scheduler@.service. Now all it takes it "systemctl start koha-mq-scheduler@INSTANCE.service" to start, but in hindsight it actually makes sense to use koha-mq-scheduler script to handle --enable, --disable, --start, --restart, and --stop. So I guess keeping the koha-* scripts makes sense but swapping out "daemon" with systemd template unit files instead. I suppose one thing to keep in mind is "adjust_paths_dev_install". I'm not familiar with that functionality. David Cook Systems Librarian Prosentient Systems 72/330 Wattle St Ultimo, NSW 2007 Australia Office: 02 9212 0899 Online: 02 8005 0595 From: Koha-devel <koha-devel-bounces@lists.koha-community.org> On Behalf Of dcook@prosentient.com.au Sent: Thursday, 4 June 2020 12:31 PM To: 'Koha Devel' <koha-devel@lists.koha-community.org> Cc: 'Victor Grousset' <victor.grousset@biblibre.com> Subject: [Koha-devel] Replace some koha-* scripts that use "daemon" with systemd unit files Hi all, What do people think about replacing some of the koha-* script files with systemd unit files? I'm creating a service for a RabbitMQ-based task scheduler and my unit file is 17 declarative configuration lines. Creating a koha-mq-scheduler file looks like it'll be hundreds of lines of shell script code. My unit file is actually a "template" file, which means I have 1 file in /etc/systemd/system/koha-mq-scheduler@.service <mailto:/etc/systemd/system/koha-mq-scheduler@.service> and I can just invoke "systemctl start koha-mq-scheduler@INSTANCE.service <mailto:koha-mq-scheduler@INSTANCE.service> " to start the service. You can use the %i placeholder in the unit file and it will be replaced with INSTANCE, so you can set paths, environmental variables, et cetera very easily. It's so easy and convenient. I think all modern Linux OSes use systemd for their init system, so I think it would be pretty safe to use. I'm happy to work on this one, but I guess I'd like to see if other people have interest in this. David Cook Systems Librarian Prosentient Systems 72/330 Wattle St Ultimo, NSW 2007 Australia Office: 02 9212 0899 Online: 02 8005 0595
On 20-06-04 04:30, dcook@prosentient.com.au wrote:
I think all modern Linux OSes use systemd for their init system, so I think it would be pretty safe to use.
I have the same impression. If someone needs to support non-systemd OSes, they could still do it (privately or in the community repo) if they have the resources to make and maintain the hundreds of lines of shell script code that you avoid by relying on systemd. Or maybe they will have another service manager that will also avoid that much work. -- Victor Grousset/tuxayo
participants (3)
-
dcook@prosentient.com.au -
Tomas Cohen Arazi -
Victor Grousset/tuxayo