Sloth
Sloth

Reputation: 53

Ruby on Rails start additional script on server startup

This is a pretty basic question, I tried searching but the question is a little obscure for Google searches.

When I start my rails server I want it to additionally start a script I wrote that just gives a feed of different system resources (i.e. CPU usage, incoming & outgoing connections, as well as alerts if resources get to high, etc.) Preferably it starts in a separate terminal windows.

Additional information if it helps any: OS: Kali Linux Ruby: 2.0.0 Rails: 4.0.3 WEBrick: 1.3.1

Upvotes: 3

Views: 2368

Answers (1)

Evolve
Evolve

Reputation: 9193

What you are wanting is Rails Initializers (guides.rubyonrails.org/configuring)

After rails starts up it then runs all the code in 'config/initializers'.

  1. Under 'config/initializers' create a new file eg 'system_resources.rb'.
  2. Initialize your code in there.

Upvotes: 2

Related Questions