package process ¶
import "github.com/Diarkis/diarkis/process"
Index ¶
- func GetShutdownTimeout() int64
- func IsRunning() bool
- func IsTerminating() bool
- func OnSIGHUP(callback func())
- func OnSIGUSR1(callback func())
- func OnSIGUSR2(callback func())
- func OnStart(task func())
- func OnStop(cb func(ctx context.Context, done func(error)))
- func OnTerminate(task func(ctx context.Context, next func(error)))
- func Start()
- func Stop()
- func StopWithCallback(done func())
- func StopWithError(err error)
Functions ¶
func GetShutdownTimeout ¶
func GetShutdownTimeout() int64
GetShutdownTimeout returns the server process shutdown timeout in seconds.
[IMPORTANT] Default is 10 seconds. [IMPORTANT] If DIARKIS_SHUTDOWN_TIMEOUT env is given, shutdown timeout changes.
func IsRunning ¶
func IsRunning() bool
IsRunning returns true if the process is running
func IsTerminating ¶
func IsTerminating() bool
IsTerminating returns true when the process is in termination mode after invoking Stop
func OnSIGHUP ¶
func OnSIGHUP(callback func())
OnSIGHUP Registers a callback function on SIGHUP signal
func OnSIGUSR1 ¶
func OnSIGUSR1(callback func())
OnSIGUSR1 Registers a callback function on SIGUSR1 signal
func OnSIGUSR2 ¶
func OnSIGUSR2(callback func())
OnSIGUSR2 Registers a callback function on SIGUSR2 signal
func OnStart ¶
func OnStart(task func())
OnStart Registers a callback on process start to be executed BEFORE the process is ready
func OnStop ¶
func OnStop(cb func(ctx context.Context, done func(error)))
OnStop registers a callback on process stop to be executed BEFORE termination tasks are executed
func OnTerminate ¶
func OnTerminate(task func(ctx context.Context, next func(error)))
OnTerminate Registers a callback on process stop to be executed BEFORE the process termination
func Start ¶
func Start()
Start Starts the process
func Stop ¶
func Stop()
Stop Stops the process with exit code 0
func StopWithCallback ¶
func StopWithCallback(done func())
StopWithCallback Stops the process and calls `done` function when the stopping process is finished.
func StopWithError ¶
func StopWithError(err error)
StopWithError Stops the process with an error and exit code 1