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