Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Sample Cron Job to check working of Whenever Gem #2715

Merged
merged 10 commits into from
May 25, 2018
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Dockerfile # Plots2
# https://github.com/publiclab/plots2

FROM ruby:2.3
FROM ruby:2.3-jessie

LABEL maintainer="Sebastian Silva <[email protected]>"
LABEL description="This image deploys Plots2."
Expand All @@ -18,7 +18,7 @@ ENV PHANTOMJS_VERSION 2.1.1
# > /etc/apt/sources.list

# Install dependencies
RUN apt-get update -qq && apt-get install -y bundler libmysqlclient-dev ruby-rmagick libfreeimage3 nodejs-legacy npm wget procps cron
RUN apt-get update -qq && apt-get install -y bundler libmysqlclient-dev ruby-rmagick libfreeimage3 nodejs-legacy npm wget procps cron make
RUN wget https://github.com/Medium/phantomjs/releases/download/v$PHANTOMJS_VERSION/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -O /tmp/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2; tar -xvf /tmp/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -C /opt ; cp /opt/phantomjs-$PHANTOMJS_VERSION-linux-x86_64/bin/* /usr/local/bin/
RUN npm install -g bower

Expand Down
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
build:
cp config/database.yml.example config/database.yml
cp db/schema.rb.example db/schema.rb
docker-compose down --remove-orphans
docker-compose build

deploy-container:
docker-compose run web sleep 5
docker-compose run web rake db:migrate
docker-compose run web bower install --allow-root
docker-compose run web bower update --allow-root
docker-compose run web rake assets:precompile
bash -c "test -e tmp/pids/server.pid && rm tmp/pids/server.pid"
docker-compose up -d
docker-compose exec -T web bash -c "echo 172.19.0.1 smtp >> /etc/hosts"
docker-compose exec -T web bundle exec whenever --update-crontab
docker-compose exec -T web service cron start

install-dev:
echo "Installing RubyGems"
bundle install --without production mysql
Expand Down
9 changes: 9 additions & 0 deletions config/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@
# end

# Learn more: http://github.com/javan/whenever

# Cron Job log file
set :output, "#{Dir.pwd}/public/cron_log.log"

# To simply print date into the log file for checking if cron job is working properly
every 1.minutes do
puts Dir.pwd
command "date -u" #This will print utc time every 1 min in log/cron_log.log file
end
Empty file added public/cron_log.log
Empty file.