I’m using letsencrypt SSL for my hass configuration, which requires certificate renewal every 3 months. To simplify the process, I have a cron job to handle the certificate renewal. However, I found that this automated approach doesn’t work until I restart the hass processes (restart from UI doesn’t take effect, must restart the processes to load the updated certificate)
Currently my hass is installed within a docker container with some other services, so the command that can be used to restart hass doesn’t work.
sudo systemctl stop/start home-assistant@pi
A work-around is to stop/start the whole container for this, but I want to avoid that as other services are also installed in the container.
I’m wondering if there is a command line option to restart hass within the container without using sysmtectl? Thanks!
You installed the other services inside the same container as HA? Why not use separate containers for those processes, would make things much easier and would increase the benefits of using Docker. And then you could just do docker restart homeassistant inside your bash script (replacing homeassistant with whatever the name of your container is).
Thanks for the prompt response! The main reason that I install the services in the same container is that they are kind of depending on each other and it’s easier for me to manage just one container. I’m also thinking just to ps | grep and then kill hass processes, but want to see if there is a cleaner way.
Agreed with @flamingm0e; this really isn’t the way to use a Docker container and I’m sure you aren’t going to be able to do what you want since there isn’t a process manager like systemd inside the container. So once you stop it how will you restart it again reliably? What happens if it dies? Docker won’t know to restart the container since HA won’t be running as part of the CMD or ENTRYPOINT process which is PID 1. You can run separate containers that depend on each other, you may just need to write a startup script that starts the containers in order or use something like Docker-compose.
Yeah, you are absolutely right. My use case is more like a VM. My main goal is to have some way to easily perform snapshots and backup my configurations. Maintaining separate containers for each of my services is kind of complicated. Since Raspberry Pi cannot support VM, so this is one way to do it. Within the container, I use Supervisor as the PID 1 process. Then Supervisor can start HA and other services I use. When HA process is killed, Supervisor will restart it automatically.
So for the original question, I’ll use pkill hass for now.