takama / daemon

A daemon package for use with Go (golang) services

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Modeling the flow of the daemon

fxfactorial opened this issue · comments

Great package, thank you.

I was wondering about the flow of the daemonization, hoping to see if my thought process is accurate.

Going off of: https://github.com/takama/daemon/blob/master/examples/cron/cron_job.go#L50

Is the idea then that:

  1. call service.Install only once needed
  2. call service.Start, this causes the usual daemonization double fork which creates its own instance but this time calling itself without a flag and hence going into the Cron working ?

Not entirely clear about 2 because I'm using cobra as a wrapper, so will that work nicely with the command line flags, arguments used by the double fork? Or should I expliclty control the commands used?

Example, I want to have it be: h-watchdog service start where I'm grouping all the daemon related commands under service subcommand.

Nvm, figured it out. Key was to understand the passing of params to .Install and using systemctl list-unit-files and systemctl show -p FragmentPath <SERVICE_NAME> to see the generated file.