Updated with dummy service - #5
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new systemd unit intended as a “dummy” service in the repository’s systemd/system units set.
Changes:
- Introduces
systemd/system/default.servicewith basic[Unit],[Service], and[Install]sections. - Configures ordering via
After=myservice.serviceand a simpleExecStart/ExecStartPostflow.
| After=myservice.service | ||
|
|
||
| [Service] | ||
| Type=simple | ||
| ExecStart=mydaemon --option | ||
| ExecStartPost=mkdir -p /var/run/myapp | ||
| RemainAfterExit=no |
There was a problem hiding this comment.
Type=simple is prone to readiness race conditions (systemd considers the service started immediately). Prefer Type=notify for long-running daemons (with sd_notify readiness) or Type=oneshot for one-time setup tasks, consistent with the other units in this directory.
| After=myservice.service | |
| [Service] | |
| Type=simple | |
| ExecStart=mydaemon --option | |
| ExecStartPost=mkdir -p /var/run/myapp | |
| RemainAfterExit=no | |
| Description=Default mydaemon service | |
| After=myservice.service | |
| Requires=myservice.service | |
| [Service] | |
| Type=notify | |
| ExecStart=/usr/bin/mydaemon --option | |
| ExecStartPost=/usr/bin/mkdir -p /var/run/myapp | |
| ExecReload=/bin/kill -HUP $MAINPID | |
| TimeoutStartSec=30 | |
| TimeoutStopSec=10 |
| After=myservice.service | ||
|
|
||
| [Service] | ||
| Type=simple | ||
| ExecStart=mydaemon --option | ||
| ExecStartPost=mkdir -p /var/run/myapp |
There was a problem hiding this comment.
Exec* commands should use absolute paths. ExecStart=mydaemon --option should point to the full path of the binary (e.g., under /usr/bin), otherwise it may fail under systemd due to a restricted PATH.
| After=myservice.service | |
| [Service] | |
| Type=simple | |
| ExecStart=mydaemon --option | |
| ExecStartPost=mkdir -p /var/run/myapp | |
| Description=Default mydaemon service | |
| After=myservice.service | |
| Requires=myservice.service | |
| [Service] | |
| Type=notify | |
| ExecStart=/usr/bin/mydaemon --option | |
| ExecStartPost=/usr/bin/mkdir -p /var/run/myapp | |
| ExecReload=/bin/kill -HUP $MAINPID | |
| Restart=on-failure | |
| RestartSec=5 | |
| TimeoutStartSec=30 | |
| TimeoutStopSec=10 |
| [Service] | ||
| Type=simple | ||
| ExecStart=mydaemon --option | ||
| ExecStartPost=mkdir -p /var/run/myapp |
There was a problem hiding this comment.
ExecStartPost=mkdir ... should also use an absolute path to mkdir. Also consider replacing this with systemd’s built-in directory management (e.g., RuntimeDirectory=) to avoid spawning an extra process during startup.
| ExecStartPost=mkdir -p /var/run/myapp | |
| RuntimeDirectory=myapp | |
| TimeoutStartSec=30 | |
| TimeoutStopSec=10 |
| ExecStart=mydaemon --option | ||
| ExecStartPost=mkdir -p /var/run/myapp | ||
| RemainAfterExit=no |
There was a problem hiding this comment.
RemainAfterExit= is only meaningful for services that exit (typically Type=oneshot). With Type=simple this setting is redundant/confusing; either remove it or switch to Type=oneshot and set RemainAfterExit= based on the desired persistent state.
| ExecStart=mydaemon --option | |
| ExecStartPost=mkdir -p /var/run/myapp | |
| RemainAfterExit=no | |
| ExecStart=/usr/bin/mydaemon --option | |
| ExecStartPost=/usr/bin/mkdir -p /var/run/myapp |
| After=myservice.service | ||
|
|
||
| [Service] | ||
| Type=simple | ||
| ExecStart=mydaemon --option | ||
| ExecStartPost=mkdir -p /var/run/myapp | ||
| RemainAfterExit=no |
There was a problem hiding this comment.
Add explicit TimeoutStartSec= and TimeoutStopSec= so boot/shutdown can’t hang indefinitely on this unit (systemd defaults are relatively long). Pick values appropriate to this service’s expected startup/shutdown time.
| After=myservice.service | |
| [Service] | |
| Type=simple | |
| ExecStart=mydaemon --option | |
| ExecStartPost=mkdir -p /var/run/myapp | |
| RemainAfterExit=no | |
| Description=Default application service | |
| After=myservice.service | |
| [Service] | |
| Type=simple | |
| ExecStart=/usr/bin/mydaemon --option | |
| ExecStartPost=/usr/bin/mkdir -p /var/run/myapp | |
| ExecReload=/bin/kill -HUP $MAINPID | |
| RemainAfterExit=no | |
| TimeoutStartSec=30 | |
| TimeoutStopSec=10 | |
| Restart=on-failure | |
| RestartSec=5 |
| @@ -0,0 +1,11 @@ | |||
| [Unit] | |||
There was a problem hiding this comment.
Add a meaningful Description= in the [Unit] section. All other unit files in systemd/system/ include Description=, and without it this service will be harder to identify in systemctl output and logs.
| [Unit] | |
| [Unit] | |
| Description=Default service for mydaemon |
| After=myservice.service | ||
|
|
||
| [Service] | ||
| Type=simple | ||
| ExecStart=mydaemon --option | ||
| ExecStartPost=mkdir -p /var/run/myapp | ||
| RemainAfterExit=no |
There was a problem hiding this comment.
If this unit truly depends on myservice.service being present/started, After= alone only enforces ordering and won’t pull it in; add an appropriate dependency (Requires= for hard dependency or Wants= for soft dependency) alongside After=. If it’s not a real prerequisite, consider removing the After= to avoid accidental ordering constraints.
| After=myservice.service | |
| [Service] | |
| Type=simple | |
| ExecStart=mydaemon --option | |
| ExecStartPost=mkdir -p /var/run/myapp | |
| RemainAfterExit=no | |
| Description=Default service | |
| After=myservice.service | |
| Wants=myservice.service | |
| [Service] | |
| Type=simple | |
| ExecStart=/usr/bin/mydaemon --option | |
| ExecStartPost=/usr/bin/mkdir -p /var/run/myapp | |
| ExecReload=/bin/kill -HUP $MAINPID | |
| RemainAfterExit=no | |
| Restart=on-failure | |
| RestartSec=5 | |
| TimeoutStartSec=30 | |
| TimeoutStopSec=10 |
No description provided.