views:

127

answers:

2

I have a script that I want to loop indefinitely outside my rails app, essentially it's just writing values over serial (with the SerialPort library), Can I just us backticks to run my script?

Lastly my biggest concern is that the script will block requests to my rails app while its running. I want it to spawn it's own process, is this possible without using one of these Background job or Workling/Starling solutions?

A: 

Launching a program via backticks will block the program that called it. What you're looking for is Drb. This link should cover everything you need to know.

EmFi
+2  A: 

If you have shell access to the box, you can use ./script/runner 'ValueWriter.run' to run any code with the rails environment.

You can use god or monit to ensure this process is running (restart it when it crashes) at all times.

Or one better, include 'config/environment' at the start of your script.

Or one better again, use script/runner, and wrap it in Daemons.

cwninja