Created
November 29, 2018 07:27
-
-
Save tgbugs/c2990382b3fdfef86a2a3a1bc0516099 to your computer and use it in GitHub Desktop.
racket servlet daemon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/sbin/openrc-run | |
# Copyright 1999-2018 Gentoo Foundation | |
# Distributed under the terms of the GNU General Public License v2 | |
: ${LOG_LEVEL:=info} | |
: ${GROUP:=servers} | |
: ${USER:=servers} | |
: ${LOG_LOC:="/var/log/servers"} | |
# useradd servers -m -d /var/lib/servers -u 950 -g 950 | |
run_dir=${run_dir:-/run} | |
LOG="${LOG_LOC}/utils.log" | |
pidfile="${run_dir}/${SVCNAME}/pid" | |
command="/usr/bin/racket" | |
command_args="~${USER}/utils-server.rkt" | |
retry='TERM/30/KILL/5' | |
command_owner="${USER}:${GROUP}" | |
depend() { | |
after net | |
} | |
start_pre() { | |
OOPS=0 | |
if [ ! -z "${TOTALLY_NOT_AN_ENVIRONMENT_VARIABLE}" ]; then | |
eend 1 "YOUR ERROR MESSAGE MADAME" | |
OOPS=1 | |
fi | |
if [ ${OOPS} -ne 0 ]; then | |
return 1 | |
fi | |
cp /home/tom/git/misc/scripts/utils-server.rkt /var/lib/${USER}/ | |
chown ${command_owner} /var/lib/${USER}/utils-server.rkt | |
checkpath --directory --owner ${command_owner} --mode 0775 "/run/${SVCNAME}" | |
checkpath --directory --owner ${command_owner} --mode 0775 "${LOG_LOC}" | |
} | |
start() { | |
ebegin "Starting utils server" | |
start-stop-daemon --start \ | |
--pidfile ${pidfile} --make-pidfile \ | |
--group ${GROUP} --user ${USER} \ | |
--background --stdout ${LOG} --stderr ${LOG} \ | |
--env MAYBE_AN_ENV=${LOL} \ | |
--exec ${command} -- ${command_args} | |
eend $? "Failed to start utils server" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment