Note: I wasn't sure if I should ask this here, stack overflow, or ???
I'm migrating a Ruby on Rails app from Heroku to AWS. The server architecture is fairly vanilla:
- Database
- Web Server
- Worker Server
The Database and Web Server have been successfully migrated to AWS. The Worker Server is on deck.
FWIW: The aws Web Server is running Ubuntu 20.x w/ Passenger / nginx as the http server.
I'm now working on migrating the Worker, which is deployed with the exact same code as the Web Server. The only difference is the Worker is not publicly accessible and uses the Ruby Gem delayed_job to process background requests.
Worker Server
- Worker server was created from an ami based off the web server.
- Removed the nginx server config that was an artifact from the web server.
Questions
How do I setup the Worker server to automatically spin up and begin running the background jobs when the server starts?
How do I keep the worker process alive if it happens to fault and shutdown?
In Heroku, the command line starting the worker server:
bundle exec rake jobs:work
After spinning up the Worker server, I can run the above command and the worker process runs great. Just need to figure out how to have the worker process run non-interactively.
FYI: I come from a Windows/.NET background. The Linux / Ruby / Rails environment is still fairly new to me.