Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Grow Your Unix Beard With Ruby

jstorimer
October 05, 2012

Grow Your Unix Beard With Ruby

jstorimer

October 05, 2012
Tweet

More Decks by jstorimer

Other Decks in Programming

Transcript

  1. @hits = Array(1..5) pid = Process.fork do @hits.delete_at(1) puts "Child

    hits: #@hits" end Process.wait(pid) puts "Parent hits: #@hits" Wednesday, 10 October, 12
  2. $hits = Array(1..5) pid = Process.fork do $hits.delete_at(1) puts "Child

    hits: #{$hits}" end Process.wait(pid) puts "Parent hits: #{$hits}" Wednesday, 10 October, 12
  3. def start open_listener_socket load_rack_app 2.times do fork { worker_loop }

    end end def worker_loop loop do connection = listener_socket.accept process_client(connection) end end Wednesday, 10 October, 12
  4. def reexec fork do cmd = [$0] cmd << ARGV.dup

    ENV['LISTENERS'] = sockets.map(&:fileno) exec(*cmd) # exec("unicorn", "-c", "unicorn_config.rb") end end Wednesday, 10 October, 12
  5. “[..] the Unix beard is really an extension of the

    philosopher's beard, and the academic's beard.” Wednesday, 10 October, 12