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

Ensure god starts correctly after first install #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions lib/moonshine/god.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,32 @@ def god(options = {})
gem 'god', :version => god_version,
:notify => exec('restart_god')

# tells god where to find the main config file
file '/etc/default/god',
file '/etc/god',
:require => package('god'),
:content => "GOD_CONFIG=/etc/god/god.conf"
:ensure => :directory

file "/etc/god/#{ENV['RAILS_ENV']}",
:require => file('/etc/god'),
:ensure => :directory

file '/etc/god', :ensure => :directory
file "/etc/god/#{ENV['RAILS_ENV']}", :ensure => :directory
# tells god to load all of the watches for this application
file "/etc/god/#{configuration[:application]}.god",
:require => file('/etc/god'),
:content => "God.load '#{configuration[:deploy_to]}/current/config/god/*.god'",
:notify => exec('restart_god')

# tells god to load all of the /etc/god/APPNAME.god
file '/etc/god/god.conf',
:require => file('/etc/god'),
:require => file("/etc/god/#{configuration[:application]}.god"),
:backup => false,
:notify => exec('restart_god'),
:content => template(god_template_dir.join('god.conf.erb'), binding)
:content => template(god_template_dir.join('god.conf.erb'), binding),
:notify => exec('restart_god')

# tells god to load all of the watches for this application
file "/etc/god/#{configuration[:application]}.god",
:require => file('/etc/god/god.conf'),
:content => "God.load '#{configuration[:deploy_to]}/current/config/god/*.god'",
:notify => exec('restart_god')
# tells god where to find the main config file
file '/etc/default/god',
:require => file('/etc/god/god.conf'),
:content => "GOD_CONFIG=/etc/god/god.conf",
:notify => exec('restart_god')

upstart_path = if Facter.value(:lsbdistrelease).to_f < 10
"/etc/event.d/god"
Expand All @@ -55,12 +61,12 @@ def god(options = {})
end

file upstart_path,
:require => file('/etc/default/god'),
:content => template(upstart_template, binding),
:notify => exec('restart_god')

exec 'restart_god',
:command => 'stop god || true && start god',
:require => file(upstart_path),
:refreshonly => true

logrotate '/var/log/god.log',
Expand Down