just-containers / s6-overlay

s6 overlay for containers (includes execline, s6-linux-utils & a custom init)
Other
3.77k stars 212 forks source link

systemd notify service conversion exmaple #548

Closed rauanmayemir closed 1 year ago

rauanmayemir commented 1 year ago

I am trying to containerize a service that is usually run under regular linux with systemd and want to ask for an example of systemd script conversion. E.g here's the systemd service definition:

[Service]
Type=notify
#User=user
NotifyAccess=all
TimeoutStartSec=5m
ExecStart=/myservice start
ExecStop=/myservice stop
Restart=on-failure
RestartSec=60s
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=myservice

How can I properly make this into a s6-rc.d v3 service definition? I've seen oneshot and longrunning definitions, but seeing notify and forking type systemd definitions, got lost wondering what to do.

skarnet commented 1 year ago

Converting systemd services to s6 (or s6-rc) services is difficult: the service models aren't similar, and they don't map to each other 1:1.

To give you an idea, here's the full list of systemd unit file keywords, rated with how hard it is to convert them to the s6 ecosystem.

If you need help with a particular service, the best thing would be to join the supervision mailing-list and post your unit file there, along with details of your service. We may be able to help you write an s6-rc service that does what you want.

As a general rule, notify and forking services cannot be converted as is, because s6 supports neither sd_notify nor cgroups to check for forking services, but there usually are alternative ways to run services that can make use of the s6 notification mechanism (for the same effect as notify) or that prevent daemons from forking (which alleviates the need for forking support).

rauanmayemir commented 1 year ago

@skarnet Thank you. I realised that simply migrating a VM instance to a container with s6 might not be as trivial as I thought it would and tabled this thought for now.

skarnet commented 1 year ago

Keep in mind that it's generally not a difficult task. It's just a difficult task to automate.

skarnet commented 1 year ago

Can I close this?