Skip to content

Embedding a falcon app (sinatra) in multithreaded ruby application #261

Answered by ioquatix
pjmelling asked this question in Q&A
Discussion options

You must be logged in to vote

Falcon is the front end application server, it's not designed for embedding, but it's made up of components you can embed. You have two options:

  • Use a service architecture, where falcon and the other parts of your application run side by side as processes.
  • Use an internal server adjacent to your main program.

There are some limits to the latter, e.g. scaling up using multiple processes, etc. I'm going that isn't a problem for you.

As such, the simplest option is to run your entire program within Async and have a separate async task for your server, e.g.

require "async"
require "async/http/server"
require "async/http/endpoint"

protocol = Async::HTTP::Protocol::HTTP2
endpoint = Async::HTTP

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by pjmelling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants