How to make Thin run on a different port?

Roman picture Roman · Sep 24, 2012 · Viewed 8k times · Source

I've a very basic test app. When I execute this command the server ignores the port I specify and runs Thin on port 4567. Why is the port I specify ignored?

$ruby xxx.rb start -p 8000

== Sinatra/1.3.3 has taken the stage on 4567 for production with backup from Thin
>> Thin web server (v1.4.1 codename Chromeo)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:4567, CTRL+C to stop

xxx.rb file

require 'Thin'

rackup_file = "config.ru" 

argv = ARGV
argv << ["-R", rackup_file ] unless ARGV.include?("-R")
argv << ["-e", "production"] unless ARGV.include?("-e")

puts argv.flatten

Thin::Runner.new(argv.flatten).run!

config.ru file

require 'sinatra'
require 'sinatra/base'

class SingingRain < Sinatra::Base
    get '/' do
        return 'hello'
    end
end

SingingRain.run!

Answer

James picture James · Sep 24, 2013
#\ -p 8000

put this at the top of the config.ru