Skip to content

Instantly share code, notes, and snippets.

@tgbugs
Created November 29, 2018 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgbugs/c2990382b3fdfef86a2a3a1bc0516099 to your computer and use it in GitHub Desktop.
Save tgbugs/c2990382b3fdfef86a2a3a1bc0516099 to your computer and use it in GitHub Desktop.
racket servlet daemon
#!/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