Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart services if required #309

Open
tobiastom opened this issue Jan 7, 2021 · 7 comments
Open

Restart services if required #309

tobiastom opened this issue Jan 7, 2021 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@tobiastom
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Coming from Ansible, I'd like to have a way inside the Bastillefile to restart a service if something has changed.

Right now I have to options:

  • SERVICE foo start: it will make sure the service is restarted. If it was not started, it will start and the possible new configuration will take effect.
  • SERVICE foo restart: If the service is already started, it will restart the service and the changes will take effect. The problem is: if the service is not started yet, it will also not be started at all.

I'd like to see a reliable way to apply Bastille Templates multiple times and if the configuration did change, it should be applied automatically.

Describe the solution you'd like
Ideally I'd like to restart (or start) a service only if something has changed. As this seems to be quite hard right now, especially with CMD and OVERLAY/RENDER combinations, I'd like to see a safe way to start a service if it is not running, but also restart it if it already was running.

I have no idea about how this feature could be named, but I'd like to use something like this inside the Bastillefile:

SERVICE foo start-or-restart

Describe alternatives you've considered
For now I used SERVICE foo start, which will never apply changes to the running service. I then restarted the jail, which could take some time and mean some service downtime, especially if other jails depend on it.

Then I tried to use SERVICE foo restart everywhere. Unfortunately this makes things works as changes to running services are applied, but they are not started on the initial creation of the jails.

@tobiastom tobiastom added the enhancement New feature or request label Jan 7, 2021
@bmac2
Copy link
Collaborator

bmac2 commented Oct 19, 2023

@tobiastom is this still an issue?? If so I can look at it but to my knowledge this works in all template deployments. If it is still an issue detail me exactly how to reproduce the issue.

@cedwards any insight on this one???

@bmac2 bmac2 self-assigned this Oct 20, 2023
@bmac2
Copy link
Collaborator

bmac2 commented Oct 22, 2023

@tobiastom inside a template there are multiple ways to accomplish this, the easiest one is use a CMD and restart the service. The template goes down the list running commands so adding a service restart at the end of the template should work. If you have any issues with this still reach out to me directly.

@bmac2 bmac2 closed this as completed Oct 22, 2023
@tobiastom
Copy link
Contributor Author

I don't think there is a proper solution for this right now, and I would argue that this issue should be reopened.

A restart will not work if the service is not running. A start will not restart it if the service configuration was changed.

@bmac2 bmac2 reopened this Oct 25, 2023
@tschettervictor
Copy link
Collaborator

tschettervictor commented Dec 4, 2024

See the output below. A restart starts the service when it is not running.

root@bill:~ # sysrc caddy_enable=yes
caddy_enable:  -> yes
root@bill:~ # service caddy status
caddy is not running.
root@bill:~ # service caddy restart
caddy not running? (check /var/run/caddy/caddy.pid).
Starting caddy... done
Log: /var/log/caddy/caddy.log

Just add SERVICE service restart inside the template.

EDIT: this might only be applicable to some services. Perhaps you can show an example of a service that doesn't work for you? @tobiastom

@bmac2
Copy link
Collaborator

bmac2 commented Jan 14, 2025

@tobiastom is a restart in the template acceptable behavior??

@tschettervictor
Copy link
Collaborator

You can also add

RESTART

to restart the entire jail, which will in turn load any new configurations.

@bmac2
Copy link
Collaborator

bmac2 commented Feb 23, 2025

@tobiastom is the two suggestions above good to solve your issue? Trying to make sure we have addressed all the issues outstanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants