davmac314 / dinit

Service monitoring / "init" system
Apache License 2.0
619 stars 49 forks source link

service restart like systemd timer or crontab after specific time period in seconds. #115

Open osevan opened 2 years ago

osevan commented 2 years ago

We need additonaly infinity loop for some services like own created daemons or scripts to start after 5 seconds for example.

I hope any plans for this kind of service are in todo list

Thanks and

Best regards

mobin-2008 commented 2 years ago

Hi! About this issue, I think that using cron is the best solution. I think it is possible to define in crontab that the service restarts every 5 seconds through dinitctl, isn't this enough? Maybe I didn't understand what you mean?!

q66 commented 1 year ago

i'm thinking of working on timers next

my idea is roughly something like this:

there would be separate timer services, with special options, but otherwise still treated like a service as in they could have dependencies and ordering hints like before = and so on; something depending on a timer unit would result in the timer service being considered "ready" immediately

an example would be something like this perhaps:

foo.timer:

type = timer
on-startup = 180 # monotonic: do not trigger unless at least 3 minutes have elapsed since dinit has started
on-active = 60 # monotonic: trigger 60 seconds after something has activated the timer unit
on-calendar = ... some syntax to specify the period ... # wallclock
trigger = some-other-service # the service to activate; perhaps mean an implicit `before =` link for this service too?
restart = true # if false, do nothing to triggered service if it's already running; if true, restart it?

some-other-service:

type = scripted
command = whatever
stop-command = whatever

but i'm not sure if/when i'll be able to get to it, plus i'm not quite sure if this design would work

it is technically possible to get timers already a bit clunkily by using https://github.com/leahneukirchen/snooze together with auto-restart, but it is not the most convenient to work with, and some things are outright impossible to do correctly (e.g. how do you say "i want to run this every day at midnight" but also "i don't want the first iteration to begin unless at least 10 minutes has elapsed since boot")

stuff like cron is even worse to work with, and perhaps even more limited because it does not integrate with service supervision at all