Skip to content

Instantly share code, notes, and snippets.

@garret-smith
Created November 24, 2015 23:35
Show Gist options
  • Save garret-smith/1caa9664f669ae18fcb5 to your computer and use it in GitHub Desktop.
Save garret-smith/1caa9664f669ae18fcb5 to your computer and use it in GitHub Desktop.
FreeBSD style daemon wrapper around relx start script
#!/bin/sh
# PROVIDE: service_name
# REQUIRE: LOGIN ntpd
# KEYWORD: shutdown
. /etc/rc.subr
name=service_name
rcvar=${name}_enable
start_cmd="${name}_start"
stop_cmd="${name}_stop"
stop_postcmd="kill_epmd"
attach_cmd="${name}_attach"
extra_commands="attach"
load_rc_config $name
: ${service_user:=username}
: ${service_enable:=no}
erts_bin=/path/to/erts-*/bin
relx_script=/path/to/bin/${name}
service_name() {
C="$relx_script $*"
su -m $service_user -c "$C"
}
service_start() {
service start
}
service_stop() {
service stop
}
service_attach() {
service attach
}
run_rc_command "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment