Compare commits
82 Commits
Author | SHA1 | Date | |
---|---|---|---|
7c584eb8ee | |||
608e7d4d9d | |||
be3d90ea79 | |||
c5bbf92022 | |||
bba7eef3d9 | |||
a0ef06810c | |||
a47b00f665 | |||
b67fec6f16 | |||
c6bba36f94 | |||
d07fd3362b | |||
e948f6985a | |||
0d95965b5b | |||
e433bdccdd | |||
a4bd260bfe | |||
7afeb29bf2 | |||
924324aa10 | |||
2aff1db42b | |||
0dd00077a5 | |||
e227235f46 | |||
5506a922c6 | |||
94bb395417 | |||
dfd942ca49 | |||
da1ffe1a7b | |||
bf85069b32 | |||
8cee6abd50 | |||
88e05630ae | |||
075d94e58c | |||
4414293f9b | |||
5c7cec8520 | |||
29bc62f208 | |||
611349e243 | |||
52f3117d3f | |||
4bcd4cc58b | |||
42f42182ae | |||
7e0df4a559 | |||
8ae151b601 | |||
2f3837d07c | |||
623bf57bdb | |||
7a3bb1a5f0 | |||
39eb1aff49 | |||
92b54483bd | |||
9516f9d5fe | |||
339ccd1b47 | |||
730374f6d7 | |||
e2ac26902c | |||
5c33fc5712 | |||
e5fc565433 | |||
d0d20d7d9c | |||
f548e6f53d | |||
9343c78b33 | |||
f026de8bb1 | |||
a715783fbf | |||
f191b625dc | |||
2d748aebc9 | |||
e733ed4f6a | |||
a5f93916cd | |||
4dee8a29b6 | |||
758e841e1e | |||
a633061d30 | |||
51d452934a | |||
3c6fb9796b | |||
08b7d5631d | |||
234ee56bed | |||
903d3e9888 | |||
025d74179b | |||
c48486cacf | |||
873f0f6809 | |||
492e2aa81b | |||
cb6b3d61df | |||
6252f8fc1e | |||
21a717762a | |||
905b3e0b37 | |||
784f4eee49 | |||
32b26b5783 | |||
6f2db37dff | |||
842662f3d5 | |||
d9f22bf634 | |||
587ed04903 | |||
8fdd73af45 | |||
34a43d4db6 | |||
253fd1f094 | |||
b13b47d1c0 |
41
README.md
41
README.md
@@ -6,5 +6,42 @@ Yet another service manager.
|
|||||||
Services
|
Services
|
||||||
--------
|
--------
|
||||||
A service is a script in the ssm's init.d directory.
|
A service is a script in the ssm's init.d directory.
|
||||||
By default it's /etc/ssm/init.d for system services and $XDG_CONFIG_HOME/ssm/init.d for user ones.
|
By default it's /etc/ssm/services for system services and $XDG_CONFIG_HOME/ssm/services for user ones.
|
||||||
ssm creates relevant dirs if they don't exist.
|
|
||||||
|
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
examples/services/iptables
Executable file
11
examples/services/iptables
Executable 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
examples/services/nginx
Executable file
8
examples/services/nginx
Executable 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
examples/services/rc.local
Executable file
9
examples/services/rc.local
Executable 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
examples/services/sshd
Executable file
10
examples/services/sshd
Executable 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
examples/services/tinc
Executable file
7
examples/services/tinc
Executable 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
examples/ssm.conf
Normal file
37
examples/ssm.conf
Normal 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
|
Reference in New Issue
Block a user