braintree / runbook

A framework for gradual system automation
MIT License
730 stars 43 forks source link

Long running processes #31

Open pitosalas opened 4 years ago

pitosalas commented 4 years ago

What's the right way to launch a process that is meant to keep on running? For example, my ruby program is a service that listens on a tcpip port until it is killed. If I start it with a simple command then the runbook blocks. If ^c the runbook then I think the service is left in limbo. This can't be right can it?

p.s. is there a gitter or slack channel on which I can more reasonably post these questions? I know you said it's ok but ...

pblesi commented 4 years ago

I'm happy to inform you that you've inspired me to set up a gitter chatroom: https://gitter.im/braintree/runbook?utm_source=share-link&utm_medium=link&utm_campaign=share-link

Is the intent to have the process run in parallel during the life of the runbook or to have the runbook start the process so it executes indefinitely? In the former case, using tmux_command is the preferred way to execute processes in parallel with the execution of the runbook. In the latter case, I would recommend using some sort of process manager to ensure your process continues to run and then to interact with your process manager to start or stop the process.

pitosalas commented 4 years ago

See followup in Gitter!

pitosalas commented 4 years ago

Reopening this question. I've set up systemctl to start up my service only to realize that my service needs to be given various tokens to run and that my go-to way of doing that was with environment variables... why in turn are not set up (obviously) when I start it with systemctl. So it seems like starting it via ssh / runback still might be a good idea. But now I am back to the question of a "long running process". Do you still recommend that I use something like systemctl and somehow give it that correct values for the environment variables?

pblesi commented 4 years ago

Yeah, I think systemctl is still the way to go. I would recommend creating configuration files in /etc/your_app. These files can contain your tokens, and you can upload the files using Runbook. Your long running process would read that file when it starts up.

coopergillan commented 2 years ago

@pitosalas - were you able to try @pblesi's suggestion here?