codetent/crypta

Start daemon as detached process

Closed this issue · 2 comments

A way needs to be found so that the daemon is started in the background, so further work with the current shell is possible. Currently only shell specific implementations like & can be used, which is not platform independent.

Proposed first draft implementation:

  • Add daemon start & daemon stop commands
  • Add a hidden flag or hidden command to daemon which runs the actual daemon
  • Extend the gRPC interface with a shutdown command

When daemon start is called, the hidden daemon command/flag is called which starts the daemon.
When daemon stop is called, the shutdown gRPC command is executed which stops the daemon gracefully.

Because the gRPC endpoints can be passed via command line arguments, this solution will also allow to start/stop multiple daemons independently of each other.

PR is closed because it does not seem to be possible to detach a process, and have it cleaned up by the init process in docker containers, especially if the init process does not check the exit status of their child processes (as is the case, e.g. for github container runners, which use tail -f as the entry point (init process)).

Crypta will draw its system boundary at the actual startup of the daemon & the CLI itself. The user of crypta can use onboard tools specific for their environment to handle the usecase of running the daemon in the background.

Proper usage (also including running the daemon in the background) will be added to the documentation though.

Documented the proper usage in #26
For now, the daemon will not be run as a detached process.