-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.ru
32 lines (25 loc) · 922 Bytes
/
config.ru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true
# This file is used by Rack-based servers to start the application.
require_relative 'config/environment'
run Rails.application
begin
if ActiveRecord::Base.connection.data_source_exists?('platforms') &&
ActiveRecord::Base.connection.data_source_exists?('channels')
Platform.find_or_initialize_by(title: 'blog').save
Platform.find_or_initialize_by(title: 'telegram').save
Platform.find_or_initialize_by(title: 'matrix').save
if Rails.configuration.credentials&.dig(:redis, :autostart)
Thread.new do
execution_context = Rails.application.executor.run!
`redis-server`
ensure
execution_context&.complete!
end
end
redis_url = Rails.configuration.credentials&.dig(:redis, :url)
REDIS = Redis.new(url: redis_url) if redis_url.present?
RunTelegramPoller.perform_now
end
rescue StandardError => e
puts(e)
end