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

What if unicorn is listening on TCP port? #1

Open
thehappycoder opened this issue Aug 26, 2013 · 3 comments
Open

What if unicorn is listening on TCP port? #1

thehappycoder opened this issue Aug 26, 2013 · 3 comments

Comments

@thehappycoder
Copy link

Can unicorn-status connect to it?

@inspire22
Copy link

Use this:

require 'rubygems'
require 'unicorn'
threshold = 3

# Poll the given socket every THRESHOLD seconds as specified above.
puts "Running infinite loop. Use CTRL+C to exit."
puts "------------------------------------------"
loop do
#  Raindrops::Linux.unix_listener_stats([socket]).each do |addr, stats|
  Raindrops::Linux.tcp_listener_stats('127.0.0.1:3001').each do |addr, stats|
    header = "Active Requests         Queued Requests"
    puts header
    puts stats.active.to_s + stats.queued.to_s.rjust(header.length - stats.active.to_s.length)
    puts "" # Break line between polling intervals, makes it easier to read
  end
  sleep threshold
end

@jahio
Copy link
Owner

jahio commented Sep 6, 2015

Wow, over two years since the original question and this is the first time I've seen this, hahaha. I really suck at GitHub notifications! :) Thanks a lot for your contribution, @inspire22, and your question @thehappycoder. I may try to factor this into the code for use via CLI switch or something in the future.

@jahio
Copy link
Owner

jahio commented Nov 3, 2017

Based on input from @inspire22 I've created the "portnum" branch on this repository with a "new version" that can accept either a socket or a port number as the first argument (and makes the interval argument optional, defaulting to 5 seconds):

./unicorn-status.rb /path/to/my.sock

or

./unicorn-status.rb 8080

I need help testing. I don't currently have a good Unicorn + Linux test environment set up and realized only after this borderline rewrite that, (duh), I can't test these features on MacOS. Thus I'd have to build up a Linux VM, set up the configuration, deploy a test app, etc. etc. before I can even know if this works at all.

Which I'll probably do when I have some time to focus on it; I would today but this already wound up needing way more time/attention than I expected.

https://github.com/jahio/unicorn-status/tree/portnum

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

No branches or pull requests

3 participants