Update jobrunner daemon again
This commit is contained in:
parent
753a5b1733
commit
be4bbb0c23
1 changed files with 9 additions and 6 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
# Logging functions
|
||||
function log() {
|
||||
echo "${*}"
|
||||
[[ -z "${JOBRUNNER_DISABLEOUTPUT}" ]] && echo "${*}"
|
||||
echo "${*}" >> "/tmp/jobrunner/jobrunner.log"
|
||||
}
|
||||
function logcmd() {
|
||||
|
@ -12,7 +12,7 @@ function logcmd() {
|
|||
}
|
||||
|
||||
# Set default timeout
|
||||
[[ -z "${JOBRUNNER_TIMEOUT}" ]] && export "JOBRUNNER_TIMEOUT=0.5s"
|
||||
[[ -z "${JOBRUNNER_TIMEOUT}" ]] && export "JOBRUNNER_TIMEOUT=0.1s"
|
||||
|
||||
# Create runtime directory
|
||||
if [ -a "/tmp/jobrunner/" ] && [ ! -d "/tmp/jobrunner/" ]; then
|
||||
|
@ -20,7 +20,9 @@ if [ -a "/tmp/jobrunner/" ] && [ ! -d "/tmp/jobrunner/" ]; then
|
|||
else
|
||||
echo ":: Creating runtime directory"
|
||||
mkdir -p "/tmp/jobrunner/"
|
||||
echo "" > /tmp/jobrunner/jobrunner.{cmd,log}
|
||||
|
||||
echo -e "" > /tmp/jobrunner/jobrunner.log
|
||||
rm -rf /tmp/jobrunner/jobrunner.cmd
|
||||
fi
|
||||
|
||||
# Check for PID file
|
||||
|
@ -46,7 +48,7 @@ while true; do
|
|||
fi
|
||||
|
||||
if [ -f "/tmp/jobrunner/jobrunner.cmd" ]; then
|
||||
log "Executing command"
|
||||
log ":: Executing command"
|
||||
|
||||
# Read command file
|
||||
JOBRUNNER_COMMAND="$(cat "/tmp/jobrunner/jobrunner.cmd")"
|
||||
|
@ -54,13 +56,14 @@ while true; do
|
|||
|
||||
# Check if contains exit action
|
||||
if [ "${JOBRUNNER_COMMAND}" == "EXIT" ]; then
|
||||
log "Exiting, as requested"
|
||||
log ":: Exiting, as requested"
|
||||
logcmd rm -rf "/tmp/jobrunner/"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Execute command in subprocess
|
||||
bash -c "${JOBRUNNER_COMMAND}" &
|
||||
echo ":: Execute: ${JOBRUNNER_COMMAND}" &>> /tmp/jobrunner/jobrunner.log
|
||||
( ${JOBRUNNER_COMMAND} ) &>> /tmp/jobrunner/jobrunner.log &
|
||||
fi
|
||||
|
||||
# Sleep specified amount
|
||||
|
|
Loading…
Reference in a new issue