88 Commits

Author SHA1 Message Date
fbt d2e432dc67 oops forgot service_tmpfiles
Signed-off-by: fbt <fbt@fleshless.org>
2026-05-24 06:17:46 +00:00
fbt f76a4e0823 Show when the service was started (this relies on the pidfile's last change time)
Signed-off-by: fbt <fbt@fleshless.org>
2026-04-13 04:01:18 +00:00
fbt 7c584eb8ee service path
Signed-off-by: fbt <fbt@fleshless.org>
2021-01-24 19:36:37 +03:00
fbt 608e7d4d9d Why
Signed-off-by: fbt <fbt@fleshless.org>
2020-12-03 19:14:21 +03:00
fbt be3d90ea79 A simpler approach
Signed-off-by: fbt <fbt@fleshless.org>
2020-03-28 19:39:54 +03:00
fbt c5bbf92022 experimental netns support and some fixes
Signed-off-by: fbt <fbt@fleshless.org>
2020-03-28 19:12:15 +03:00
fbt bba7eef3d9 There is no passthru anymore
Signed-off-by: fbt <fbt@fleshless.org>
2020-03-07 18:50:02 +03:00
fbt a0ef06810c shaky, abort
Signed-off-by: fbt <fbt@fleshless.org>
2020-02-11 03:00:24 +03:00
fbt a47b00f665 We always know the mainpid, why the cloak & dagger
Signed-off-by: fbt <fbt@fleshless.org>
2019-11-17 17:48:51 +03:00
fbt b67fec6f16 Another experiment
Signed-off-by: fbt <fbt@fleshless.org>
2019-11-17 17:35:19 +03:00
fbt c6bba36f94 this works always
Signed-off-by: fbt <fbt@fleshless.org>
2018-12-19 19:07:39 +03:00
fbt d07fd3362b tiny QoL improvement
Signed-off-by: fbt <fbt@fleshless.org>
2018-08-07 23:04:35 +03:00
fbt e948f6985a a flag for remembering service configs
Signed-off-by: fbt <fbt@fleshless.org>
2018-04-08 16:54:23 +03:00
fbt 0d95965b5b oops
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-09 07:58:34 +03:00
fbt e433bdccdd consistency
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-09 07:50:20 +03:00
fbt a4bd260bfe These should go into stderr
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-09 07:23:57 +03:00
fbt 7afeb29bf2 Some ideas were dumb
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-09 07:19:18 +03:00
fbt 924324aa10 I'm lazy
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-09 06:57:26 +03:00
fbt 2aff1db42b Keep the state yo
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-09 05:57:26 +03:00
fbt 0dd00077a5 info fixes
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-09 03:25:49 +03:00
fbt e227235f46 examples, oneshot services rework
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-09 02:31:14 +03:00
fbt 5506a922c6 quote expansions
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-08 23:57:44 +03:00
fbt 94bb395417 Oops
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-06 19:47:42 +03:00
fbt dfd942ca49 change namespacing from :: to service::
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-06 19:42:31 +03:00
fbt da1ffe1a7b enforce strict service name rules
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-06 19:30:04 +03:00
fbt bf85069b32 oops. This makes more sense.
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-06 18:29:30 +03:00
fbt 8cee6abd50 cleanup & setup
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-06 18:21:21 +03:00
fbt 88e05630ae Signal passthru and support for $service_name::function style namespacing
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-06 17:42:10 +03:00
fbt 075d94e58c Separate the svc pidfile and the service one
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-06 07:40:02 +03:00
fbt 4414293f9b readme
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-05 04:45:26 +03:00
fbt 5c7cec8520 readme
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-05 04:41:55 +03:00
fbt 29bc62f208 reset-exit fix
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-05 04:28:35 +03:00
fbt 611349e243 early edit; list known
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-05 03:42:30 +03:00
fbt 52f3117d3f Remove stale pidfiles in the respawn loop
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-05 02:52:55 +03:00
fbt 4bcd4cc58b Silly ssm, search where you lost it, not where it is light
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-05 02:01:26 +03:00
fbt 42f42182ae cgroup cleanup
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-05 01:36:40 +03:00
fbt 7e0df4a559 +#service_cgroup_cleanup
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-05 01:13:55 +03:00
fbt 8ae151b601 A feature to kill the cgroup members when stopping the service
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-05 01:01:57 +03:00
fbt 2f3837d07c cgroup tweaks
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-05 00:35:29 +03:00
fbt 623bf57bdb exit code and failure states rework
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-05 00:16:45 +03:00
fbt 7a3bb1a5f0 respawn rework
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-04 19:26:40 +03:00
fbt 39eb1aff49 Respawn cleanup and new features; usage
Signed-off-by: fbt <fbt@fleshless.org>
2018-03-04 16:55:53 +03:00
fbt 92b54483bd these should also be readonly
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-22 20:08:48 +03:00
fbt 9516f9d5fe Found how to break it
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-10 22:00:22 +03:00
fbt 339ccd1b47 Turned out not to be very useful
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-10 11:30:02 +03:00
fbt 730374f6d7 more sugar
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-09 23:47:50 +03:00
fbt e2ac26902c A switch to disable checking if the service pid is in the correct cgroup
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-09 16:53:02 +03:00
fbt 5c33fc5712 A very old bug indeed
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-08 14:22:13 +03:00
fbt e5fc565433 artefact of old
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-08 14:17:02 +03:00
fbt d0d20d7d9c separate cfg files after all; some cleanup
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-08 14:12:34 +03:00
fbt f548e6f53d oops
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-08 12:08:01 +03:00
fbt 9343c78b33 ssm.conf
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-08 12:02:02 +03:00
fbt f026de8bb1 this ignores whitespace
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-08 11:52:40 +03:00
fbt a715783fbf More cgroup stuff
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-08 10:33:06 +03:00
fbt f191b625dc rudimentary cgroup support
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-08 08:07:18 +03:00
fbt 2d748aebc9 can only 'return' from a function or sourced script
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-08 05:58:23 +03:00
fbt e733ed4f6a logfile cleanup
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-08 05:48:40 +03:00
fbt a5f93916cd ooops :3
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-08 04:52:15 +03:00
fbt 4dee8a29b6 some cleanup
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-08 04:47:42 +03:00
fbt 758e841e1e var
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-08 04:38:24 +03:00
fbt a633061d30 Some more systemd work, a simple DSL
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-07 12:02:12 +03:00
fbt 51d452934a Ho about this then
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-07 09:12:12 +03:00
fbt 3c6fb9796b Another oops
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-07 08:56:33 +03:00
fbt 08b7d5631d oops
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-07 08:47:23 +03:00
fbt 234ee56bed Rudimentary support for systemd services
Signed-off-by: fbt <fbt@fleshless.org>
2018-01-07 08:36:39 +03:00
fbt 903d3e9888 small fix
Signed-off-by: fbt <fbt@fleshless.org>
2017-12-21 16:53:58 +03:00
fbt 025d74179b edit()
Signed-off-by: fbt <fbt@fleshless.org>
2017-12-21 16:12:53 +03:00
fbt c48486cacf just some silly refactoring
Signed-off-by: fbt <fbt@fleshless.org>
2017-12-16 00:36:32 +03:00
fbt 873f0f6809 rogue debug change, reverting
Signed-off-by: fbt <fbt@fleshless.org>
2017-12-14 18:42:12 +03:00
fbt 492e2aa81b Make internal functions readonly
Signed-off-by: fbt <fbt@fleshless.org>
2017-12-14 18:41:03 +03:00
fbt cb6b3d61df Merge branch 'master' of builder.priv:spark/ssm 2017-12-14 07:10:56 +03:00
fbt 6252f8fc1e Merge branch 'master' of builder.priv:spark/ssm
Signed-off-by: fbt <fbt@fleshless.org>
2017-12-14 07:10:29 +03:00
fbt 21a717762a Merge branch 'master' of builder.priv:spark/ssm 2017-12-14 07:09:43 +03:00
fbt 905b3e0b37 Full path; default workdir
* Determine our full path and use that instead of /bin/zsh
* Default workdir for all services is now '/'

Signed-off-by: fbt <fbt@fleshless.org>
2017-12-14 07:08:32 +03:00
fbt 784f4eee49 Determine our full path and use that instead of /bin/zsh
Signed-off-by: fbt <fbt@fleshless.org>
2017-12-14 07:07:48 +03:00
fbt 32b26b5783 cfg_path bugfix
Signed-off-by: fbt <fbt@fleshless.org>
2017-12-10 20:13:51 +03:00
fbt 6f2db37dff Show the config path in the info
Signed-off-by: fbt <fbt@fleshless.org>
2017-12-10 19:48:22 +03:00
fbt 842662f3d5 Actually, let's move softly
Signed-off-by: fbt <fbt@fleshless.org>
2017-12-10 19:42:25 +03:00
fbt d9f22bf634 init.d -> services
Signed-off-by: fbt <fbt@fleshless.org>
2017-12-10 19:27:51 +03:00
fbt 587ed04903 init.d and reverse functions load order
Signed-off-by: fbt <fbt@fleshless.org>
2017-12-08 16:49:34 +03:00
fbt 8fdd73af45 More flexibility
Signed-off-by: fbt <fbt@fleshless.org>
2017-12-08 16:39:05 +03:00
fbt 34a43d4db6 also search for services in a package dir
Signed-off-by: fbt <fbt@fleshless.org>
2017-12-08 15:16:03 +03:00
fbt 253fd1f094 default can do arrays now
Signed-off-by: fbt <fbt@fleshless.org>
2017-12-08 14:39:50 +03:00
fbt b13b47d1c0 show the full service command; do not escape the pager
Signed-off-by: fbt <fbt@fleshless.org>
2017-11-14 16:58:53 +03:00
fbt 8173828c62 stopped services and workdir
Signed-off-by: fbt <fbt@fleshless.org>
2017-11-09 04:19:26 +03:00
fbt 3ead5f0492 better readaility
Signed-off-by: fbt <fbt@fleshless.org>
2017-07-13 16:25:41 +03:00
fbt a921025ce9 oops
Signed-off-by: fbt <fbt@fleshless.org>
2017-07-13 16:20:57 +03:00
fbt 33d35654fc licence and readme
Signed-off-by: fbt <fbt@fleshless.org>
2017-07-13 15:45:56 +03:00
9 changed files with 1017 additions and 359 deletions
+13
View File
@@ -0,0 +1,13 @@
Copyright (c) 2017+, Jack L. Frost <fbt@fleshless.org>
Permission to use, copy, modify, and/or distribute this software for any purpose with or without
fee is hereby granted, provided that the above copyright notice and this permission notice appear
in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
OF THIS SOFTWARE.
+47
View File
@@ -0,0 +1,47 @@
ssm
===
Yet another service manager.
Services
--------
A service is a script in the ssm's init.d directory.
By default it's /etc/ssm/services for system services and $XDG_CONFIG_HOME/ssm/services for user ones.
Note that they are BASH scripts that get sourced by `ssm`. Same pitfalls apply.
Hopefully, you won't have to do complex logic in the services.
## Global settings
* `cgroups = 0` — Enable cgroup-related features.
## Service config
Mandatory options:
* `service_command = /usr/bin/example -a --long-arg "parameter"`
Optional settings (incomplete list):
* `service_respawn = no` — Restart the service. Takes `no`, `always`, `on-failure` and `on-success`.
* `service_workdir = /`
* `service_pidfile` — If the service manages its own pidfile, set this.
* `service_pidfile_timeout = 15` — How long to wait for the service to create its pidfile.
* `service_pidfile_remove_stale = yes` — Remove stale pidfiles before spawning the service process.
* `service_logfile_out = "$logdir/$service_name.log"` — Logfile for output.
* `service_logfile_err = "$service_logfile_out"` — Logfile for stderr.
* `service_stop_timeout = 30` — How long to wait after sending the stop command.
* `service_ready_timeout = 15` — How long to wait till the service is ready, in seconds.
* `service_stop_signal = 15` — Which signal to send to the service when stopping.
* `service_reload_signal = 1` — Which signal to send to the service when reloading.
* `service_cgroup_exclusive = no` — Refuse to start the service if the cgroup is not empty.
* `service_cgroup_wait = no` — Wait on the entire cgroup to die when stopping the service.
* `service_cgroup_strict = 1` — Refuse to do anything if the service's recorded PID is both running and not in the service's appropriate cgroup. This usually means you've either found a bug or something bad happened to your system.
* `service_cgroup_kill = no` — Kill the entire cgroup when stopping the service.
* `service_cgroup_kill_signal = 15` — Which signal to use for that.
* `service_cgroup_cleanup = no` — Kill the entire cgroup on watchdog cleanup. Note that it is distinctly not the same as killing the cgroup on stopping.
* `service_success_exit = 0` — Array. Which exit codes to treat as successful termination. Only works for managed services (With no custom pidfile).
* `service_oneshot = no` — The service is supposed to do something and die instead of daemonizing.
* `service_signals_passthru` — Array, empty by default. Which signals should the svc pass directly to the service mainpid. This is dangerous, use with caution.
Mind your expansions.
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env ssm
service_oneshot = true
service_command = /usr/bin/false
service::pre_start() {
cat <<- EOF
Please don't. Use ferm or any other wrapper.
You will just reinvent one in here anyway.
EOF
}
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/env ssm
service_respawn = on-failure
service_command = /usr/bin/nginx
service_pidfile = /run/nginx.pid
# Do not reload the service if the config test fails.
pre_reload() { "$service_command" -t "$@"; }
+9
View File
@@ -0,0 +1,9 @@
#!/usr/bin/env ssm
service_type = oneshot
service_command = /etc/rc.local
pre_start() {
# Do nothing, successfully, if /etc/rc.local is not executable.
[[ -x "/etc/rc.local" ]] || die 0
}
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env ssm
service_respawn = always
service_command = /usr/bin/sshd -D -f "/etc/ssh/sshd_config"
pre_start() {
if ! [[ -e "/etc/ssh/ssh_host_key" ]]; then
ssh-keygen -A
fi
}
+7
View File
@@ -0,0 +1,7 @@
#!/usr/bin/env ssm
# This trick was neat back in 2011, I swear
var tinc_network = "${service_name##*-}"
service_respawn = on-failure
service_command = /usr/bin/tincd -D -n "$tinc_network"
+37
View File
@@ -0,0 +1,37 @@
# This is actually a bash script
# Where to search for services, works as a PATH-like array.
#service_path = "$XDG_CONFIG_HOME/ssm/services" /etc/ssm/services "$rundir/services" /usr/share/ssm/services
# Service defaults
# Respawn the service if it exits
#service_respawn = 0
# Working directory
#service_workdir = '/'
# How long do we wait for the service to stop
#service_stop_timeout = 30
# How long do we wait for the service to get ready
#service_ready_timeout = 15
# The signal to send to reload the service
#service_reload_signal = 1
# The signal to send to stop the service
#service_stop_signal = 15
# Enable cgroup-related functions
# Only works with cgroups v2 and a helper.
# Basically, don't.
#
#cgroups = 1
# Refuse to start the service if its cgroup is not empty
#service_cgroup_exclusive = 0
# Wait on all the members of the cgroup to exit when stopping the service.
#service_cgroup_wait = 0
#service_cgroup_strict = 0
+875 -359
View File
File diff suppressed because it is too large Load Diff