Skip to content

Commit

Permalink
use flock for scheduled task
Browse files Browse the repository at this point in the history
  • Loading branch information
stanstrup committed Jun 24, 2019
1 parent 948aa61 commit f89956b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions setup/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ COPY ./setup /srv/shiny-server/QC4Metabolomics/setup/


FROM base AS process
##### Scheduled jobs ######################################################
##### Scheduled jobs ##########################################################
RUN apt-get update && \
apt-get install -y \
\
Expand All @@ -84,7 +84,7 @@ RUN apt-get update && \


RUN R -e "BiocManager::install('bnosac/cronR')"
RUN R -e "library(cronR);cmd <- cron_rscript('/srv/shiny-server/QC4Metabolomics/setup/scheduled_tasks.R', rscript_log = '/var/log/QC_cron.log');cron_add(cmd, frequency = '*/1 * * * *', id = 'QC_processing', description = 'Process files every 1 minute')"
RUN R -e "library(cronR);cmd <- cron_rscript('/srv/shiny-server/QC4Metabolomics/setup/scheduled_tasks.sh', cmd = '/bin/bash', rscript_log = '/var/log/QC_cron.log');cron_add(cmd, frequency = '*/1 * * * *', id = 'QC_processing', description = 'Process files every 1 minute')"
###############################################################################


Expand Down
2 changes: 2 additions & 0 deletions setup/scheduled_tasks.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
message("====================================================\nRunning scheduled tasks at: ", Sys.time(), "\n====================================================")

setwd("/srv/shiny-server/QC4Metabolomics/")
source(".Rprofile")

Expand Down
5 changes: 5 additions & 0 deletions setup/scheduled_tasks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

[ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -n "$0" "$0" "$@" || :

/usr/local/bin/Rscript '/srv/shiny-server/QC4Metabolomics/setup/scheduled_tasks.R'

0 comments on commit f89956b

Please sign in to comment.