Created
January 29, 2013 14:13
-
-
Save mindscratch/4664524 to your computer and use it in GitHub Desktop.
Run puma with control server for a Sinatra 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
| # Usage: rackup config.ru | |
| require 'gollum' | |
| require 'gollum/frontend/app' | |
| require 'puma' | |
| Precious::App.set(:gollum_path, Dir.pwd) | |
| Precious::App.set(:server, :puma) | |
| Precious::App.run! do |server| | |
| @options = {control_url: 'tcp://0.0.0.0:9293', control_auth_token: 'foo'} | |
| if str = @options[:control_url] | |
| require 'puma/app/status' | |
| uri = URI.parse str | |
| cli = nil | |
| app = Puma::App::Status.new server, cli | |
| if token = @options[:control_auth_token] | |
| app.auth_token = token unless token.empty? or token == :none | |
| end | |
| status = Puma::Server.new app, server.events | |
| status.min_threads = 0 | |
| status.max_threads = 1 | |
| case uri.scheme | |
| when "tcp" | |
| server.events.log "* Starting status server on #{str}" | |
| status.add_tcp_listener uri.host, uri.port | |
| when "unix" | |
| server.events.log "* Starting status server on #{str}" | |
| path = "#{uri.host}#{uri.path}" | |
| status.add_unix_listener path | |
| else | |
| server.events.error "Invalid status URI: #{str}" | |
| end | |
| status.run | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment