Sha256: 4d15de6eca06c489c2105f67008985fd81e005777f2e5a44ff5c645460528c49
Contents?: true
Size: 929 Bytes
Versions: 45
Compression:
Stored size: 929 Bytes
Contents
class Redde::SystemCommand attr_accessor :action ALLOWED_ACTIONS = %w(cache unicorn sidekiq reboot).freeze def self.execute(action) new(action).process end def initialize(action) @action = action Logger.new('log/commands.log').info "Received #{action} command" fail "Unsopported command #{action}. Allowed commands: #{ALLOWED_ACTIONS.join(', ')}" unless ALLOWED_ACTIONS.include?(action.to_s) end def process send(action) end private def cache `sudo service memcached restart` end def unicorn `sudo service #{project_name} restart` end def sidekiq system("sudo kill `cat #{Rails.root}/tmp/pids/sidekiq.pid` && cd #{Rails.root} && RAILS_ENV=#{Rails.env} bundle exec sidekiq -C config/sidekiq.yml -L log/sidekiq.log -d") end def reboot `sudo reboot` end def project_name Rails.root.to_s.gsub('/current', '').split('/').last end end
Version data entries
45 entries across 45 versions & 1 rubygems