greenpau / caddy-appd

Service Management App for Caddy v2
Apache License 2.0
30 stars 1 forks source link

question: Can this do systemd socket activation? #1

Closed gc-ss closed 3 months ago

gc-ss commented 2 years ago

Thank You for making this!

  1. Can this do systemd socket activation?
  2. If I had a dockerized program - say hey that's pretty taxing on the system and that I wish to run on demand (and deactivate when done), how would I go about that here?
almereyda commented 2 years ago

We're orchestrating Docker programs with libre.sh ¹ here, which brings a convenient systemd wrapper for Compose. This would allow you to solve the necessary condition above, with your containers then being able to be orchestrated by "libre.sh".

To answer your sufficient condition, the first question, you could possibly configure the socket alongside the automatically generated unit (when created with libre enable). The latter could also profit from omitting the PreExec=docker-compose rm -sf step, in so stopped, pre-existing containers can "boot" almost instantly.

Then what remains is the question on how to schedule the suspension of a running docker container. This could possibly happen similarly to a health-check, or a misused one, which the containerised application exposes to the host, in order to allow the scheduler to evaluate a suspend trigger. Next to any other way to forcibly halt a systemd unit.


Edit: Inspiration can be taken from the https://github.com/acouvreur/traefik-ondemand-plugin, where they drop containers with help of https://github.com/acouvreur/traefik-ondemand-service after a timeout following the last request.

Another implementation of a Traefik plugin that fulfills the OPs requirements is https://github.com/adyanth/traefik-container-manager with https://github.com/acouvreur/traefik-ondemand-service.


¹ https://lab.libreho.st/libre.sh/compose.libre.sh

greenpau commented 2 years ago

@almereyda , I did not finalize this plugin yet. Will update this issue when I do.

gedw99 commented 2 years ago

Its an area i am also interested in.

I dont know if its just me but this seems to be begging to help enable easy to use self hosted serverless.

docker and non docker actually.

you could stick a async broker in front of this and hold a request, start up the service, then let the request through. where the async broker is is sort of another question...

greenpau commented 2 years ago

Its an area i am also interested in.

@gedw99 , I didn't get to this plugin in a while. I will let you know once I get back to it.

Currently the plugin is WIP and I need to do some wiring to make it work.

greenpau commented 3 months ago

FYI, I am changing the scope of this plugin. It will only perform startup and shutdown of applications.

gedw99 commented 3 months ago

@greenpau

It's basically like Goreman and Overmind. ? They both use a ProcFile and run many things for you .

I dont know why you dont just import Goreman which works on all OS's too, just like caddy

https://github.com/mattn/goreman

greenpau commented 3 months ago

@gedw99 , I am not familiar with goreman. The main reason I just want to use stdgolib and incorporate the logic that I need. No proc files. I will release this week and you can take a look at the code.

greenpau commented 3 months ago

@gedw99 , I released v1.0.4. It contains all the things I needed at the moment.

gedw99 commented 3 months ago

Thanks @greenpau

I found a a golang runner that has erlang supervision trees which I needed so that things run and cleanly update on users edge systems. Edge systems is a priority . So all desktops , not just Linux.

https://github.com/cirello-io/runner

I will study your also @greenpau