Reputation: 48525
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?
Upvotes: 1
Views: 547
Reputation: 9778
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.
Upvotes: 2