Sha256: 32120cce9cf31e0083d78cf235c81a8c597328478c4ae79d7bd981e8e7cf6530

Contents?: true

Size: 1.93 KB

Versions: 23

Compression:

Stored size: 1.93 KB

Contents

require 'erb'

namespace :god do
  desc "Generate a stub god config file template for the daemon"
  task :template => 'environment' do
    # Preserve local changes
    if File.exists?( "#{DaemonKit.root}/config/god.erb" ) && ENV['FORCE'].nil?
      puts "Template already exists, use FORCE=1 to overwrite."
      exit 1
    end

    cp "#{DaemonKit.framework_root}/templates/god/god.erb", "#{DaemonKit.root}/config/god.erb"
  end

  desc "Parse the god config template into a god config file"
  task :generate => 'environment' do

    unless File.exists?( "#{DaemonKit.root}/config/god.erb" )
      Rake::Task["god:template"].invoke
    end

    name = DaemonKit.configuration.daemon_name

    File.open( "#{DaemonKit.root}/config/#{name}.god", "w+" ) do |f|
      t = File.read( "#{DaemonKit.root}/config/god.erb" )
      f.write( ERB.new( t ).result( binding )  )
    end

    puts "god config generated in config/#{name}.god"
  end

  desc "Load the god file into god"
  task :load => 'environment' do
    name = DaemonKit.configuration.daemon_name

    sh "#{$RAKE_USE_SUDO ? 'sudo' : ''} god load #{DaemonKit.root}/config/#{name}.god"
  end

  desc "Refresh the god config file in the running god"
  task :refresh => 'environment' do
    name = DaemonKit.configuration.daemon_name

    sh "#{$RAKE_USE_SUDO ? 'sudo' : ''} god unmonitor #{name}"
    sh "#{$RAKE_USE_SUDO ? 'sudo' : ''} god remove #{name}"
    sh "#{$RAKE_USE_SUDO ? 'sudo' : ''} god load #{DaemonKit.root}/config/#{name}.god"
    sh "#{$RAKE_USE_SUDO ? 'sudo' : ''} god monitor #{name}"
  end

  desc "Start god monitoring of the config file"
  task :monitor => 'environment' do
    name = DaemonKit.configuration.daemon_name

    sh "#{$RAKE_USE_SUDO ? 'sudo' : ''} god monitor #{name}"
  end

  desc "Stop god monitoring of the config file"
  task :unmonitor => 'environment' do
    name = DaemonKit.configuration.daemon_name

    sh "#{$RAKE_USE_SUDO ? 'sudo' : ''} god unmonitor #{name}"
  end
end

Version data entries

23 entries across 23 versions & 3 rubygems

Version Path
daemon-kit-0.3.3 lib/daemon_kit/tasks/god.rake
daemon-kit-0.3.2 lib/daemon_kit/tasks/god.rake
daemon-kit-0.3.1 lib/daemon_kit/tasks/god.rake
daemon-kit-0.3.0 lib/daemon_kit/tasks/god.rake
daemon-kit-0.3.0.rc2 lib/daemon_kit/tasks/god.rake
daemon-kit-0.3.0.rc1 lib/daemon_kit/tasks/god.rake
daemon-kit-0.2.3 lib/daemon_kit/tasks/god.rake
daemon-kit-0.2.1 lib/daemon_kit/tasks/god.rake
daemon-kit-0.2.0 lib/daemon_kit/tasks/god.rake
daemon-kit-0.1.8.2 lib/daemon_kit/tasks/god.rake
amqp-daemon-kit-1.0.1 lib/daemon_kit/tasks/god.rake
amqp-daemon-kit-0.1.8.2 lib/daemon_kit/tasks/god.rake
amqp-daemon-kit-0.1.8.1 lib/daemon_kit/tasks/god.rake
daemon-kit-0.1.8.1 lib/daemon_kit/tasks/god.rake
daemon-kit-0.1.8 lib/daemon_kit/tasks/god.rake
daemon-kit-0.1.8rc3 lib/daemon_kit/tasks/god.rake
textgoeshere-daemon-kit-0.1.8.31 lib/daemon_kit/tasks/god.rake
textgoeshere-daemon-kit-0.1.8rc3 lib/daemon_kit/tasks/god.rake
daemon-kit-0.1.8rc2 lib/daemon_kit/tasks/god.rake
daemon-kit-0.1.8rc1 lib/daemon_kit/tasks/god.rake