How to create a rack application that Rails will use?

The rails themselves are based on several independent processes that do not have internetwork requests. I need to add a centralized stateful service (game machine) to my Rails application.

From the fact that I know little, I have to make this service state-stable. Is there any tutorial on how to make a rack application, and it is also important how to communicate with it with Rails. What is the idiomatic way to deploy it with Rails and idiomatic place to put it in my git Rails code base?

+4
source share
2 answers

Another question answered my question:

How to read POST data in a rack request

require 'json' class Greeter def call(env) req = Rack::Request.new(env) if req.post? puts req.POST() end [200, {"Content-Type" => "application/json"}, [{x:"Hello World!"}.to_json]] end end run Greeter.new 

and use JSON.parse( req.body.read ) to parse the POST data.

+2
source

Another option besides the rack is daemonize your application.

0
source

Source: https://habr.com/ru/post/1468928/


All Articles