Fixing cron not updating inside docker

pull/107/head^2
alse 5 years ago
parent fc553f2938
commit 42e677d8d2

@ -1,7 +1,9 @@
# docker run -d -p 8000:8000 alseambusher/crontab-ui
FROM alpine:3.10
RUN mkdir /crontab-ui; touch /etc/crontabs/root; chmod +x /etc/crontabs/root
ENV CRON_PATH /etc/crontabs
RUN mkdir /crontab-ui; touch $CRON_PATH/root; chmod +x $CRON_PATH/root
WORKDIR /crontab-ui
@ -24,7 +26,6 @@ ENV HOST 0.0.0.0
ENV PORT 8000
ENV CRON_PATH /etc/crontabs
ENV CRON_IN_DOCKER true
EXPOSE $PORT

@ -1,4 +1,4 @@
VER=0.3.9
VER=0.3.12
release:
sed -i '' "s/version\": \".*/version\": \"$(VER)\",/" package.json

@ -131,22 +131,16 @@ exports.set_crontab = function(env_vars, callback){
fs.writeFile(exports.env_file, env_vars, function(err) {
if (err) callback(err);
// In docker we're running as the root user, so we need to write the file as root and not crontab
var fileName = "crontab"
if(process.env.CRON_IN_DOCKER !== undefined) {
fileName = "root"
}
var fileName = process.env.CRON_IN_DOCKER !== undefined ? "root" : "crontab";
fs.writeFile(path.join(cronPath, fileName), crontab_string, function(err) {
if (err) return callback(err);
/// In docker we're running crond using busybox implementation of crond
/// It is launched as part of the container startup process, so no need to run it again
if(process.env.CRON_IN_DOCKER === undefined) {
exec("crontab " + path.join(cronPath, "crontab"), function(err) {
if (err) return callback(err);
else callback();
});
} else {
callback();
}
exec("crontab " + path.join(cronPath, fileName), function(err) {
if (err) {
console.error(err);
return callback(err);
}
else callback();
});
});
});
});

@ -1,6 +1,6 @@
{
"name": "crontab-ui",
"version": "0.3.11",
"version": "0.3.12",
"description": "Easy and safe way to manage your crontab file",
"main": "index.js",
"scripts": {

Loading…
Cancel
Save