unicorn -c unicorn.conf.rb
Last active
December 23, 2015 11:29
-
-
Save groundwater/6628306 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# require another part of our app | |
require "./worker" | |
# load some webapp | |
# can be anything | |
app = lambda do |env| | |
[ | |
200, | |
{ 'Content-Type' => 'text/html' }, | |
'Hello World' | |
] | |
end | |
run app |
This file contains hidden or 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
# start 20 child processes | |
worker_processes 20 | |
after_fork do |server, worker| | |
# assign the worker number to a global variable | |
$nr = worker.nr | |
end |
This file contains hidden or 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
# from a child, pull the global variable to get the number | |
puts "#{Process.pid} => #{$nr}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment