2

We have a decently big Rails app. However, the restful APIs are slow.

Hence, we are prototyping to move the API layer outside of Rails. We are currently considering grape (https://github.com/intridea/grape) which will remove ActiveRecord and other heavy Rails code. The whole API layer will be in core Ruby.

To manage connection pools with PG we are have written a piece of code that opens n number of DB connections and maintains them. Whenever we want to run a query, we use one of those connections and then return them back to the available pool.

Now, we want to somehow run the connection pool generation code to RACKUP server start. So when the RACK server starts all the connection pools are open and stored in RAM.

Any idea how we can invoke certain code at start of RACKUP server?

Thank you in advance

Pykih
  • 2,769
  • 3
  • 29
  • 38

1 Answers1

0

This is what config.ru is for. I use it to load a lib that watches unicorns and kills/restarts them when they reach certain memory thresholds. Your system administrator may possibly manage the config.ru, if you don't see it in your project. I like having it in the source tree personally.

Joe McDonagh
  • 163
  • 6