部署基于eventmachine的rails应用程序

时间:2015-12-30 07:06:13

标签: ruby-on-rails eventmachine

在本地部署rails web app时,我在端口3000启动瘦服务器,EventMachine在8080监听websocket请求但是如何将其部署到Heroku或者是否有其他适合此应用的Backend服务? 这是启动Eventmachine循环的代码

EM.run {
  EM::WebSocket.run(:host => "0.0.0.0", :port => 8080) do |ws|
    ws.onopen { |handshake|
    puts "WebSocket connection open"

    # Access properties on the EM::WebSocket::Handshake object, e.g.
    # path, query_string, origin, headers

    # Publish message to the client
    ws.send "Hello Client, you connected to #{handshake.path}"
    }

    ws.onclose { puts "Connection closed" }

    ws.onmessage { |msg|
    puts "Recieved message: #{msg}"
    ws.send "Pong: #{msg}"
    }
  end

0 个答案:

没有答案