simplified cron runner.

This commit is contained in:
Abdulmhsen B. A. A
2022-04-18 21:17:43 +03:00
parent 6d5ccdf62e
commit 453eb323fb
2 changed files with 21 additions and 13 deletions

View File

@@ -1,25 +1,33 @@
#!/usr/bin/env sh
UID=$(id -u)
NOW=$(date +"%Y_%m_%d")
WS_UID=${WS_UID:-1000}
WS_GID=${WS_GID:-1000}
WS_CRON_DEBUG=${WS_CRON_DEBUG:-'v'}
# check for data path.
if [ -z "${WS_DATA_PATH}" ]; then
WS_DATA_PATH="/config"
fi
if [ "1" == "${WS_CRON_IMPORT}" ] || [ "1" == "${WS_CRON_EXPORT}" ] || [ "1" == "${WS_CRON_PUSH}" ]; then
LOGFILE="${WS_DATA_PATH}/logs/cron/${NOW}.log"
LOGFILE="${WS_DATA_PATH}/logs/cron/${NOW}.log"
if [ ! -d "${WS_DATA_PATH}/logs/cron/" ]; then
# Check cron logs path.
if [ ! -d "${WS_DATA_PATH}/logs/cron/" ]; then
if [ 0 == "${UID}" ]; then
runuser -u www-data -- mkdir -p "${WS_DATA_PATH}/logs/cron/"
else
mkdir -p "${WS_DATA_PATH}/logs/cron/"
fi
if [ ! -f "${LOGFILE}" ]; then
runuser -u www-data -- touch "${LOGFILE}"
chown ${WS_UID}:${WS_GID} "${LOGFILE}"
fi
/usr/bin/console scheduler:run -o >>"${LOGFILE}"
fi
if [ 0 == "${UID}" ]; then
OUTPUT=$(runuser -u www-data -- /usr/bin/console scheduler:run -o -${WS_CRON_DEBUG})
else
OUTPUT=$(/usr/bin/console scheduler:run -o -${WS_CRON_DEBUG})
fi
if [ ! -z "${OUTPUT}" ]; then
echo ${OUTPUT} >${LOGFILE}
fi

View File

@@ -36,7 +36,7 @@ if [ ! -f "/usr/bin/run-app-cron" ]; then
chmod +x /usr/bin/run-app-cron
fi
if [ 0 == "${WS_NO_CHOWN}" ]; then
if [ -z "${WS_NO_CHOWN}" ]; then
chown -R www-data:www-data /config /var/lib/nginx/
fi
@@ -45,12 +45,12 @@ fi
/usr/bin/console storage:migrations
/usr/bin/console storage:maintenance
if [ 0 == "${WS_DISABLE_HTTP}" ]; then
if [ -z "${WS_DISABLE_HTTP}" ]; then
echo "Starting Nginx server.."
nginx
fi
if [ "1" == "${WS_CRON_IMPORT}" ] || [ "1" == "${WS_CRON_EXPORT}" ] || [ "1" == "${WS_CRON_PUSH}" ]; then
if [ -z "${WS_DISABLE_CRON}" ]; then
echo "Starting cron..."
/usr/sbin/crond -b -l 2
fi