class Ridoku::Maintenance

Attributes

app[RW]

Public Instance Methods

run() click to toggle source
# File lib/ridoku/maintenance.rb, line 13
def run
  clist = Base.config[:command]
  command = clist.shift
  sub_command = clist.shift

  case sub_command
  when 'on'
    maintenance(true)
  when 'off'
    maintenance(false)
  when 'status', nil
    status
  else
    print_maintenance_help
  end
end

Protected Instance Methods

maintenance(maint) click to toggle source
# File lib/ridoku/maintenance.rb, line 32
def maintenance(maint)
  Base.fetch_stack
  Base.fetch_app

  Base.custom_json['deploy'][Base.app[:shortname]]['maintenance'] = maint
  Base.save_stack

  Ridoku::Cook.cook_recipe_on_layers('deploy::maintenance', ['rails-app'],
    deploy: {
      Base.app[:shortname] => {
        application_type: 'rails'
      }
    }
  )
  status
end
print_maintenance_help() click to toggle source
status() click to toggle source
# File lib/ridoku/maintenance.rb, line 49
def status
  Base.fetch_stack
  Base.fetch_app

  $stdout.print 'Maintenance: '

  app_json = Base.custom_json['deploy'][Base.app[:shortname]]

  if app_json.key?('maintenance')
    maint = (app_json['maintenance'] == true)
    $stdout.puts $stdout.colorize((maint ? 'on' : 'off'),
      [:bold, (maint ? :red : :green)])
  else
    $stdout.puts $stdout.colorize('off', :green)
  end
end