Created
October 2, 2014 07:18
-
-
Save hSATAC/ffbf9065b498fdb1ff60 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
#! /usr/bin/ruby | |
require "rubygems" | |
require "net/http" | |
require "socket" | |
SOCKET_PATH = '/Users/cat/kkbox/kktix/unicorn.sock' | |
def unicorn_ready | |
return false unless File.exist? SOCKET_PATH | |
return true if unicorn_return.to_i == 200 | |
end | |
def unicorn_return | |
sock = Net::BufferedIO.new(UNIXSocket.new(SOCKET_PATH)) | |
request = Net::HTTP::Get.new("/") | |
request.exec(sock, "1.1", "/") | |
begin | |
response = Net::HTTPResponse.read_new(sock) | |
end while response.kind_of?(Net::HTTPContinue) | |
response.reading_body(sock, request.response_body_permitted?) { } | |
response.code | |
end | |
puts "Waiting for unicorn_rails..." | |
(sleep 1; print ".") until unicorn_ready | |
`/etc/init.d/nginx start` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment