0

I am using Cuba for some basic testing and learning.

I have some code like below which works fine. Thin starts and works well with Cuba and I can use EM for websockets etc..

I want to now place nginx in front of Thin so I've followed some tutorials and basically given a upstream of 127.0.0.1:3000 which also works fine.

What I can't get working is removing the Thin::Server.start Cuba, '0.0.0.0', 3000 line and moving the starting of Thin into it's YAML config file in /etc/thin/site_config.yml so I can start 4 servers and define the threadpool_size etc..

How can I remove or change the Thin::Server.start Cuba, '0.0.0.0', 3000 line so the bind port and number of servers/ports is not defined in the code but instead managed by the Thin config.yml file ?

app.rb

require 'cuba'
require 'thin'
require 'em-websocket'

Cuba.plugin(Mote::Render)

EM.run do

  Thin::Server.start Cuba, '0.0.0.0', 3000

  Cuba.define do
    on get do

      on "hello" do
        res.write "Hello world!"
      end  

    end

end

config.ru

require "./app"

run Cuba

thin config file

---
chdir: "/var/www/html/snow"
environment: production
address: 0.0.0.0
port: 3000
timeout: 30
log: "/var/log/thin.log"
pid: tmp/pids/thin.pid
max_conns: 1024
max_persistent_conns: 100
require: []
wait: 30
threadpool_size: 20
servers: 3
daemonize: true
Flo Woo
  • 949
  • 1
  • 12
  • 26

0 Answers0