docker: add cron service to compose file.
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -53,6 +53,7 @@ gem 'ed25519'
|
|||||||
gem 'bcrypt_pbkdf' # https://github.com/net-ssh/net-ssh/issues/565
|
gem 'bcrypt_pbkdf' # https://github.com/net-ssh/net-ssh/issues/565
|
||||||
gem 'terminal-table'
|
gem 'terminal-table'
|
||||||
gem 'newrelic_rpm', require: false
|
gem 'newrelic_rpm', require: false
|
||||||
|
gem 'clockwork'
|
||||||
|
|
||||||
group :production, :staging do
|
group :production, :staging do
|
||||||
gem 'unicorn', :platforms => :ruby
|
gem 'unicorn', :platforms => :ruby
|
||||||
|
|||||||
@@ -145,6 +145,9 @@ GEM
|
|||||||
xpath (~> 3.2)
|
xpath (~> 3.2)
|
||||||
childprocess (3.0.0)
|
childprocess (3.0.0)
|
||||||
chronic (0.10.2)
|
chronic (0.10.2)
|
||||||
|
clockwork (2.0.4)
|
||||||
|
activesupport
|
||||||
|
tzinfo
|
||||||
codecov (0.5.2)
|
codecov (0.5.2)
|
||||||
simplecov (>= 0.15, < 0.22)
|
simplecov (>= 0.15, < 0.22)
|
||||||
coderay (1.1.3)
|
coderay (1.1.3)
|
||||||
@@ -494,6 +497,7 @@ DEPENDENCIES
|
|||||||
capistrano-rbenv
|
capistrano-rbenv
|
||||||
capistrano3-unicorn
|
capistrano3-unicorn
|
||||||
capybara
|
capybara
|
||||||
|
clockwork
|
||||||
codecov
|
codecov
|
||||||
daemons
|
daemons
|
||||||
delayed_job
|
delayed_job
|
||||||
|
|||||||
22
config/initializers/clockwork.rb
Normal file
22
config/initializers/clockwork.rb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Define cronjobs using the clockwork gem; see https://github.com/Rykian/clockwork.
|
||||||
|
# Use `bin/rails danbooru:cron` to start the cron process.
|
||||||
|
#
|
||||||
|
# See also `app/logical/danbooru_maintenance.rb`.
|
||||||
|
|
||||||
|
module Clockwork
|
||||||
|
every(1.hour, "hourly", at: "**:00") do
|
||||||
|
DanbooruMaintenance.hourly
|
||||||
|
end
|
||||||
|
|
||||||
|
every(1.day, "daily", at: "00:00") do
|
||||||
|
DanbooruMaintenance.daily
|
||||||
|
end
|
||||||
|
|
||||||
|
every(1.week, "weekly", at: "Sunday 00:00") do
|
||||||
|
DanbooruMaintenance.weekly
|
||||||
|
end
|
||||||
|
|
||||||
|
every(1.month, "monthly", at: "00:00") do
|
||||||
|
DanbooruMaintenance.monthly
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -21,7 +21,7 @@ version: "3.4"
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
danbooru:
|
danbooru:
|
||||||
image: danbooru
|
image: evazion/danbooru
|
||||||
ports:
|
ports:
|
||||||
- "80:3000"
|
- "80:3000"
|
||||||
environment:
|
environment:
|
||||||
@@ -36,15 +36,25 @@ services:
|
|||||||
command: ["bash", "-c", "bin/rails db:setup; bin/rails db:migrate && bin/rails server -b 0.0.0.0"]
|
command: ["bash", "-c", "bin/rails db:setup; bin/rails db:migrate && bin/rails server -b 0.0.0.0"]
|
||||||
user: root
|
user: root
|
||||||
|
|
||||||
delayed_jobs:
|
cron:
|
||||||
image: danbooru
|
image: evazion/danbooru
|
||||||
environment:
|
environment:
|
||||||
- RAILS_ENV=production
|
- RAILS_ENV=production
|
||||||
- DATABASE_URL=postgresql://danbooru@postgres/danbooru
|
- DATABASE_URL=postgresql://danbooru@postgres/danbooru
|
||||||
- DANBOORU_CANONICAL_URL=http://localhost
|
- DANBOORU_CANONICAL_URL=http://localhost
|
||||||
depends_on:
|
depends_on:
|
||||||
- danbooru
|
- danbooru
|
||||||
command: ["bash", "-c", "bin/wait-for-http http://danbooru:3000 3s && bin/delayed_job run"]
|
command: ["bash", "-c", "bin/wait-for-http http://danbooru:3000 5s && bin/rails danbooru:cron"]
|
||||||
|
|
||||||
|
delayed_jobs:
|
||||||
|
image: evazion/danbooru
|
||||||
|
environment:
|
||||||
|
- RAILS_ENV=production
|
||||||
|
- DATABASE_URL=postgresql://danbooru@postgres/danbooru
|
||||||
|
- DANBOORU_CANONICAL_URL=http://localhost
|
||||||
|
depends_on:
|
||||||
|
- danbooru
|
||||||
|
command: ["bash", "-c", "bin/wait-for-http http://danbooru:3000 5s && bin/delayed_job run"]
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: evazion/postgres
|
image: evazion/postgres
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
namespace :danbooru do
|
namespace :danbooru do
|
||||||
|
desc "Run the cronjob scheduler"
|
||||||
|
task cron: :environment do
|
||||||
|
Clockwork::run
|
||||||
|
end
|
||||||
|
|
||||||
namespace :docker do
|
namespace :docker do
|
||||||
# Note that uncommited changes won't be included in the image; commit
|
# Note that uncommited changes won't be included in the image; commit
|
||||||
# changes first before building the image.
|
# changes first before building the image.
|
||||||
|
|||||||
Reference in New Issue
Block a user