diff --git a/src/scheduler.js b/src/scheduler.js index 811551585..bfc8408b6 100644 --- a/src/scheduler.js +++ b/src/scheduler.js @@ -61,9 +61,11 @@ function createJobs(app, schedulerConfig, callback) { // stopJobs only deletes jobs since previous run. This means that when box code restarts, none of the containers // are removed. The deleteContainer here ensures we re-create the cron containers with the latest config docker.deleteContainer(containerName, function ( /* ignoredError */) { - docker.createSubcontainer(app, containerName, [ '/bin/sh', '-c', cmd ], { } /* options */, function (error) { + docker.createSubcontainer(app, containerName, [ '/bin/sh', '-c', cmd ], { } /* options */, function (error, container) { if (error && error.reason !== BoxError.ALREADY_EXISTS) return iteratorDone(error); + debug(`createJobs: ${taskName} will run in container ${container.id}`); + var cronJob = new CronJob({ cronTime: cronTime, // at this point, the pattern has been validated onTick: () => runTask(appId, taskName, (error) => { // put the app id in closure, so we don't use the outdated app object by mistake @@ -143,7 +145,7 @@ function sync() { }); }); }, function (error) { - if (error) return debug('sync: error creating jobs', error); + if (error) return debug('sync: error creating jobs', error.message); }); }); }); diff --git a/src/scripts/starttask.sh b/src/scripts/starttask.sh index 1c6f2ead8..a9458c9a3 100755 --- a/src/scripts/starttask.sh +++ b/src/scripts/starttask.sh @@ -26,7 +26,7 @@ readonly nice="$3" readonly memory_limit_mb="$4" readonly service_name="box-task-${task_id}" -systemctl reset-failed "${service_name}" || true +systemctl reset-failed "${service_name}" 2>/dev/null || true readonly id=$(id -u $SUDO_USER) readonly ubuntu_version=$(lsb_release -rs) @@ -42,7 +42,7 @@ else [[ "$BOX_ENV" == "cloudron" ]] && options="${options} -p BindsTo=box.service" fi -# systemd 237 on Ubunut 18.04 does not apply --nice +# systemd 237 on ubuntu 18.04 does not apply --nice if [[ "${ubuntu_version}" == "18.04" ]]; then (sleep 1; pid=$(systemctl show "${service_name}" -p MainPID | sed 's/MainPID=//g'); renice -n ${nice} -g ${pid} || true) & fi