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

Needs some status on the Unicorn #1

Open
kaspergrubbe opened this issue Jan 25, 2013 · 0 comments
Open

Needs some status on the Unicorn #1

kaspergrubbe opened this issue Jan 25, 2013 · 0 comments

Comments

@kaspergrubbe
Copy link
Owner

Something like

# Displays the current status of the server(s)
#
desc "Displays server status"
task :status, :roles => :app do
  find_servers(:roles => :app).each do |server|
    run "touch #{fetch(:unicorn_pid)}", :hosts => [server]
    pid = capture "cat #{fetch(:unicorn_pid)}", :hosts => [server]
    if pid.to_i > 0 # Server is running
      workers = capture("ps uxww | grep unicorn | grep #{fetch(:application)} | grep #{fetch(:rails_env)} | grep worker ", :hosts => [server]).split("\n").reject{ |l| l.include?("sh -c") }.count
      logger.info "#{server.to_s.ljust(20)}: Server running #{workers} workers on pid #{pid.to_i}"
    else # Server is not running
      logger.info "#{server.to_s.ljust(20)}: Server _NOT_ running!"
    end
  end
end

But simplified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant