Fixing cron not updating inside docker

pull/107/head^2
alse 2020-06-08 22:34:42 +05:30
parent fc553f2938
commit 42e677d8d2
4 changed files with 13 additions and 18 deletions

View File

@ -1,7 +1,9 @@
# docker run -d -p 8000:8000 alseambusher/crontab-ui # docker run -d -p 8000:8000 alseambusher/crontab-ui
FROM alpine:3.10 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 WORKDIR /crontab-ui
@ -24,7 +26,6 @@ ENV HOST 0.0.0.0
ENV PORT 8000 ENV PORT 8000
ENV CRON_PATH /etc/crontabs
ENV CRON_IN_DOCKER true ENV CRON_IN_DOCKER true
EXPOSE $PORT EXPOSE $PORT

View File

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

View File

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

View File

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