Skip to content

Commit a61556b

Browse files
committed
IIRR-21: Add Procfile
IIRR-21: Bump up pg gem IIRR-21: Update database.yml IIRR-21: Add sidekiq initialiser IIRR-21: Add scheduler key to sidekiq.yml
1 parent c582501 commit a61556b

6 files changed

Lines changed: 38 additions & 13 deletions

File tree

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ gem "dotenv-rails"
99

1010
gem "propshaft"
1111
# Use postgresql as the database for Active Record
12-
gem "pg", "~> 1.1"
12+
gem "pg", "~> 1.5.9"
1313
# Use the Puma web server [https://github.com/puma/puma]
1414
gem "puma", ">= 5.0"
1515
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ DEPENDENCIES
420420
importmap-rails
421421
jbuilder
422422
kamal
423-
pg (~> 1.1)
423+
pg (~> 1.5.9)
424424
propshaft
425425
puma (>= 5.0)
426426
rails (~> 8.0.2)

Procfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
release: rake db:migrate
2+
web: bundle exec puma -C config/puma.rb
3+
worker: bundle exec sidekiq -c 2 -q default
4+
bot: bundle exec rake discord:start_bot

config/database.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ default: &default
1818
# For details on connection pooling, see Rails configuration guide
1919
# https://guides.rubyonrails.org/configuring.html#database-pooling
2020
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
21+
port: 5432
22+
username: <%= ENV["DB_USERNAME"] || "postgres" %>
23+
password: <%= ENV["DB_PASSWORD"] %>
24+
host: <%= ENV["DB_HOST"] || "localhost" %>
25+
timeout: 5000
2126

2227

2328
development:
@@ -81,9 +86,7 @@ test:
8186
production:
8287
primary: &primary_production
8388
<<: *default
84-
database: ruby_or_rails_production
85-
username: ruby_or_rails
86-
password: <%= ENV["RUBY_OR_RAILS_DATABASE_PASSWORD"] %>
89+
url: <%= ENV["DATABASE_URL"] %>
8790
cache:
8891
<<: *primary_production
8992
database: ruby_or_rails_production_cache

config/initializers/sidekiq.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require "sidekiq"
2+
3+
# Heroku generates a rediss URL but since
4+
# the SSL certificate is self-signed, verification throws an error.
5+
Sidekiq.configure_server do |config|
6+
config.redis = {
7+
url: ENV.fetch("REDIS_URL", "redis://localhost:6379/0"),
8+
ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
9+
}
10+
end
11+
12+
Sidekiq.configure_client do |config|
13+
config.redis = {
14+
url: ENV.fetch("REDIS_URL", "redis://localhost:6379/0"),
15+
ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
16+
}
17+
end

config/sidekiq.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
:schedule:
2-
daily_puzzle_job:
3-
cron: "0 9 * * *" # This runs the job at 9:00 AM every day
4-
class: "SendDailyPuzzleJob"
5-
6-
weekly_puzzle_job:
7-
cron: "0 0 * * 0" # This runs the every Sunday at midnight
8-
class: "SendWeeklyPuzzleJob"
1+
:scheduler:
2+
:schedule:
3+
daily_puzzle_job:
4+
cron: "0 9 * * *" # This runs the job at 9:00 AM every day
5+
class: "SendDailyPuzzleJob"
6+
7+
weekly_puzzle_job:
8+
cron: "0 0 * * 0" # This runs the every Sunday at midnight
9+
class: "SendWeeklyPuzzleJob"

0 commit comments

Comments
 (0)