How Do I Restart Applications From CLI/Script?

The subject says it all: how do I restart applications from the command line or a zsh script?

I’m using using letsencrypt certificates with an unsupported (in TrueNAS Scale or NPM) DNS provider (mythic beasts), so need to copy certs generated elsewhere into the nginx-proxy-manager folder and restart the application to make them live.

Please don’t suggest I change my DNS provider, use traefik, or any other major infrastructure/workflow change.

I haven’t done anything like this myself, but I suspect that you can probably use the API (which is a network call using WebSocket or RESTful API protocol) using the chart.release.scale or chart.release.scale_workloads calls to scale the number of instances down to zero (stop) or up to one (start) to start and stop an app.

The documentation is available in the web interface of your TrueNAS install by appending /api/docs to the domain name of your TrueNAS server.

1 Like

Thanks, I’ll have a look

another option would be to use heavyscript which has already a restart option for the k3s apps, but that will stop working when truenas switches to docker from kubernetes in oktober.

Well, fortunately I know enough about docker to be able to easily stop and start containers. It’s because of my complete lack of k3s experience that I’m asking this now :slight_smile:

Hmm, having global 2FA turned on seems to preclude restful API access from a script

Well, some Googling later and I think I have a solution via:

k3s kubectl -n ix-nginx-proxy-manager rollout restart deploy

This will restart all pods in the ix-nginx-proxy-manager namespace, which is handy as the NPM application consists of two pods, npm and mariadb. TrueNAS makes this easy for us by putting all the pods required by a given app in the same namespace.

You can see all the pods, and their namespaces, by running:

k3s kubectl get pods --all-namespaces