Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make a systemd script #50

Closed
davidcoutadeur opened this issue Apr 20, 2018 · 9 comments · Fixed by #260
Closed

Make a systemd script #50

davidcoutadeur opened this issue Apr 20, 2018 · 9 comments · Fixed by #260
Assignees
Milestone

Comments

@davidcoutadeur
Copy link
Contributor

I don't think this issue was proposed previously, so I post it here.
It was first proposed by [email protected] in the mailing list (2018-02-13 13:50 GMT+01:00)

[Unit]
Description=LSC sync broker
After=network.target

[Service]
PrivateTmp=true
PIDFile=/run/lsc.pid
Type=oneshot
#Environment=JAVA_HOME=/usr/jvm/lib/latest
User=lsc
Group=lsc
ExecStart=/opt/lsc/bin/lsc -a all -f /opt/lsc/etc

[Install]
WantedBy=multi-user.target

Need to be tested.

@coudot coudot added this to the 2.2 milestone Feb 10, 2020
@coudot
Copy link
Member

coudot commented Jul 15, 2021

Check that we can read logs with journalctl

@bendem
Copy link

bendem commented Aug 16, 2022

PIDFile is not required with Type=oneshot. We run lsc from systemd with a few more hardening options (I believe ExecStart and ReadWritePaths are specific to our setup, they should be made generic).

[root@ldap-test-01 lsc]# systemctl cat lsc-main
# /etc/systemd/system/lsc-main.service
#
# Ansible managed
#
[Unit]
Description=Run LSC jobs | main

[Service]
Type=oneshot
ExecStart=/etc/lsc/run-main
User=lsc
Group=lsc

PrivateTmp=true
PrivateDevices=true
ProtectSystem=strict
ProtectKernelTunables=yes
ProtectControlGroups=yes
ReadWritePaths=/var/log/lsc
UMask=0007

[Install]
WantedBy=multi-user.target

@artlog
Copy link
Contributor

artlog commented Sep 26, 2022

taking a look.

davidcoutadeur pushed a commit that referenced this issue Oct 6, 2023
@davidcoutadeur
Copy link
Contributor Author

davidcoutadeur commented Oct 6, 2023

I have proposed a systemd example in #230

  • it runs lsc -f /etc/lsc -s all
  • stdout logs are displayed in journalctl -xeu lsc.service

Certainly not perfect because the admin still needs to adapt the synchronization options (-s, -c, -a)

@coudot coudot linked a pull request Oct 12, 2023 that will close this issue
@coudot
Copy link
Member

coudot commented Oct 12, 2023

Solution to test: use the standard way to override a systemd service : https://askubuntu.com/questions/659267/how-do-i-override-or-configure-systemd-services

@davidcoutadeur
Copy link
Contributor Author

I have added a new commit (6b9afd7) for:

  • adding debian package recipes
  • adding RHEL package recipes
  • fixing some minor things
  • renaming the systemd service names and corresponding default files, which I didn't find meaningful:

lsc-oneshot -> lsc-sync
lsc -> lsc-async
/etc/default/lsc-examplesynctask -> /etc/default/lsc-sync
/etc/default/lsc-examplesynctask -> /etc/default/lsc-async

with these new rules, it is easier to understand which task is intended to be launched with which default file.

I have tested the new packages:

  • debian 12: build ok, install ok, running ok
  • rockylinux 9: build ok, install ok, running impossible because systemd not available on my container. But everything seems well-deployed.

@xavierba : I have some new remarks:

  1. could you give a look and tell me if it is ok for you?
  2. BuildRequires: systemd makes it impossible to build the package on debian systems. (which worked before...) Too bad... but if you have an alternative, feel free!
  3. I didn't get this from your PR: %systemd_postun_with_restart lsc.service, because I am not sure if it is a good idea to restart the service when doing an upgrade, whatever the use case. (but I confess I am not sure of the meaning of systemd_postun_with_restart in this situation)
  4. when everything will be ok, could you resolve conflicts in RPM specfile cleanup #246 ?

davidcoutadeur pushed a commit that referenced this issue Jan 19, 2024
davidcoutadeur pushed a commit that referenced this issue Jan 19, 2024
@davidcoutadeur
Copy link
Contributor Author

As pointed out by @xavierba , we should take advantage of this issue to drop the support of init.d.
I am favourable for doing so, because systemd is now the default component:

  • since centos 7
  • since debian 8

Anyway, we no longer support lsc packages for OS older that these.

If everyone is ok with that, I am going to remove init.d in #260

@coudot
Copy link
Member

coudot commented Jan 19, 2024

If everyone is ok with that, I am going to remove init.d in #260

Ok for me

@davidcoutadeur
Copy link
Contributor Author

davidcoutadeur commented Jan 19, 2024

systemd scripts seems ready in #260
I am going to merge.

What I have done since last review:

  • removed /etc/init.d/lsc support
  • removed useless sed on /etc/default/lsc-* files (since these variables are now defined in corresponding systemd unit files)
  • fix pid filename directly in systemd unit file
  • removed %systemd_preun [email protected] since systemd doesn't know which instance to stop (even with a joker)
  • removed /etc/default/lsc (since not used any more)
  • clean and simplify /etc/default/lsc-sync and /etc/default/lsc-async
  • write the documentation (see https://github.com/lsc-project/documentation/blob/main/source/run.rst#using-systemd-service)
  • test build + install + run + remove on debian12: OK
  • test build + install +run + remove on rocky9: OK (warnings during preinstall, but not due to systemd)
  • split long lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants