Browse Source

Using the /etc/crontabs/root file

pull/56/head
Corey Gaspard 7 years ago
parent
commit
acc9016d39
  1. 4
      Dockerfile
  2. 8
      crontab.js
  3. 2
      supervisord.conf

4
Dockerfile

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

8
crontab.js

@ -115,8 +115,12 @@ exports.set_crontab = function(env_vars, callback){
fs.writeFile(exports.env_file, env_vars, function(err) {
if (err) callback(err);
fs.writeFile(path.join(cronPath, "crontab"), crontab_string, function(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"
}
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

2
supervisord.conf

@ -2,7 +2,7 @@
nodaemon=true
[program:crontab]
command=crond -l 2 -f -c %(CRON_PATH)s
command=crond -l 2 -f -c %(ENV_CRON_PATH)s
stderr_logfile = /var/log/crontab-stderr.log
stdout_logfile = /var/log/crontab-stdout.log

Loading…
Cancel
Save