2

I am trying to create a Chef cookbook that will run Hashicorp Consul in the background and will continue with the rest of the recipe and not get hung on starting Consul.

I have tried the & method at the end of the command but when chef-client exits it kills the process and will not let me run any checks / testing against Consul.

Anyone have a suggestion on how to resolve this? I know I have seen a few implementations where they use ruby scripts but I would like to avoid that as I suck at ruby. Also do not want to use another cookbook from online, rather make my own to learn how as this is a learning project.

1

The usual way to do that is to use a service manager (systemd or supervisord) to handle the service lifecycle (keeping the consul program running and restarting it if it fails for exemple) there's cookbooks existing to help creating those service units.

The cheap alternative if you count on chef running periodically and handling that is to use nohup which is a linux program made exactly for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.