god
god copied to clipboard
God load crashes when dependencies are required from god config files
Maybe I'm doing things wrong, but I have defined some custom God notifier plugins, and I need to load those dependencies before starting god for the first time.
But then, when I try to release a new app version (I'm deploying with Capistrano), my flow is to update God config using god load
. Problem, this causes crashes when I require modules that extend ActiveSupport::Concern
and have included
blocks with the following error
Cannot define multiple 'included' blocks for a Concern
Here is a sample of my God file (Note that <%= %>
are compiled before execution)
require 'active_support/all'
require 'slack-notifier'
require '<%= release_path.join("lib/service_connector") %>'
require '<%= release_path.join("lib/slack_connector") %>'
require '<%= release_path.join("lib/god/contacts/slack_notifier") %>'
God.contact(:email) do |c|
God.contact(:slack_notifier) do |c|
c.name = 'priority-errors'
c.group = 'developers'
c.webhook = '<%= Capistrano::SecretsYml.local_secrets_yml("deploy")&.dig("slack") %>'
end
My restart task with Capistrano
desc "Restart god's child processes"
task :restart do
on roles(fetch(:god_roles)) do
within release_path do
with RAILS_ENV: fetch(:rails_env) do
if god_is_running?
execute :bundle, 'exec god load config/god/god.rb'
execute :bundle, 'exec god restart'
else
start_god
end
end
end
end
end
The execute :bundle, 'exec god load config/god/god.rb'
command