Created
October 11, 2010 07:52
-
-
Save jordansissel/620190 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% sudo ruby ruby-supervisorctl.rb | |
[ | |
[0] [ | |
[0] { | |
:state => 30, | |
:stdout_logfile => "/tmp/falsetest-stdout---supervisor-bqdUwO.log", | |
:now => 1286783537, | |
:start => 1286783530, | |
:group => "falsetest", | |
:stderr_logfile => "/tmp/falsetest-stderr---supervisor-1kKclr.log", | |
:logfile => "/tmp/falsetest-stdout---supervisor-bqdUwO.log", | |
:pid => 0, | |
:description => "Exited too quickly (process log may have details)", | |
:spawnerr => "Exited too quickly (process log may have details)", | |
:stop => 1286783530, | |
:name => "falsetest", | |
:statename => "BACKOFF", | |
:exitstatus => 0 | |
}, | |
[1] { | |
:state => 10, | |
:stdout_logfile => "/tmp/mysqld-stdout---supervisor-ZEfmqr.log", | |
:now => 1286783537, | |
:start => 1286783536, | |
:group => "mysqld", | |
:stderr_logfile => "/tmp/mysqld-stderr---supervisor-PmY9aS.log", | |
:logfile => "/tmp/mysqld-stdout---supervisor-ZEfmqr.log", | |
:pid => 14431, | |
:description => "", | |
:spawnerr => "", | |
:stop => 1286783535, | |
:name => "mysqld", | |
:statename => "STARTING", | |
:exitstatus => 0 | |
} | |
] | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of using ruby's net/http to send requests to a webserver listening on | |
# a unix socket. Traditionally this is awkward because most http libraries only | |
# support TCP sockets. Luckily, the net/http module is written in a modular | |
# way so we can reuse the HTTP features on our own socket. | |
require "net/http" | |
require "socket" | |
require "rubygems" | |
require "xml/libxml/xmlrpc" # gem libxml-xmlrpc | |
require "ap" # gem awesome_print | |
# Net::HTTP requests internally use Net::BufferedIO, so we must, too. | |
sock = Net::BufferedIO.new(UNIXSocket.new("/var/run/supervisor.sock")) | |
# Make a new request, exec it on our unix socket. | |
request = Net::HTTP::Post.new("/RPC2") | |
request.content_type = "text/xml" | |
# See http://supervisord.org/api.html | |
# Call supervisor.getAllProcessInfo | |
request.body = XML::XMLRPC::Builder.call("supervisor.getAllProcessInfo") | |
request.exec(sock, "1.1", "/RPC2") | |
# Wait for and parse the http response. | |
begin | |
response = Net::HTTPResponse.read_new(sock) | |
end while response.kind_of?(Net::HTTPContinue) | |
response.reading_body(sock, request.response_body_permitted?) { } | |
# Parse the XMLRPC response | |
xml = XML::XMLRPC::Parser.new(response.body) | |
ap xml.params |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment