# README
Cerberus
Cerberus is a Windows service helper program inspired by NSSM.
It can be used to create and manage Windows services for ordinary binaries.
Usage
Help Options:
-h, --help Show this help message
Available commands:
edit Editing an installed service
install Install a binary as service
list Show cerberus installed services
recovery Editing recovery actions for an installed service
remove Removes an installed service
run Runs a configured service
version Show version
Install
Usage:
cerberus_64.exe [OPTIONS] install [install-OPTIONS]
Install a binary as service
Help Options:
-h, --help Show this help message
[install command options]
-v, --verbose Verbose output
-x, --executable= Full path to the executable
-w, --workdir= Working directory of the executable, if not specified
the folder of the executable is used.
-n, --name= Name of the service, if not specified name of the
executable is used.
-i, --display-name= Display name of the service, if not specified name of
the executable is used.
-d, --desc= Description of the service
-a, --arg= Arguments to pass to the executable in the same order
as specified. (ex. -a "-la" -a "123")
-e, --env= Environment variables to set for the executable. (ex.
-e "TERM=bash" -e "EDITOR=none")
Edit
Usage:
cerberus_64.exe [OPTIONS] edit [edit-OPTIONS] SERVICE_NAME
Editing an installed service
Help Options:
-h, --help Show this help message
[edit command options]
-v, --verbose Verbose output
-w, --workdir= Working directory of the executable..
-i, --display-name= Display name of the service.
-d, --desc= Description of the service
-a, --arg= Arguments to pass to the executable in the same
order as specified. (ex. -a "-la" -a "123")
-e, --env= Environment variables to set for the
executable. (ex. -e "TERM=bash" -e
"EDITOR=none")
-n, --dependencies= Services on which this service depend on. (ex.
-a serviceA -a serviceB)
-u, --user= User under which this service will run.
-p, --password= Password for the specified service user.
-s, --start-type= Service start type. One of
[manual|autostart|delayed|disabled]
--signal-ctrlc Send Ctrl-C to process if service has to stop.
--signal-wmquit Send WM_QUIT to process if service has to stop.
--signal-wmclose Send WM_CLOSE to process if service has to stop.
--no-signal Restore default behaviour and doesn't send any
signals.
--no-deps Remove all dependencies for this service.
--no-args Remove all arguments for this service.
--no-env Remove all environment variables for this
service.
--use-system-account Use local system account to run this service.
[edit command arguments]
SERVICE_NAME: Name of the service to edit.
Remove
Usage:
cerberus_64.exe [OPTIONS] remove [remove-OPTIONS] SERVICE_NAME
Removes an installed service
Help Options:
-h, --help Show this help message
[remove command options]
-v, --verbose Verbose output
[remove command arguments]
SERVICE_NAME: Name of the service to remove.
Recovery Actions
Usage:
cerberus_64.exe [OPTIONS] recovery set [set-OPTIONS] SERVICE_NAME ARGUMENTS...
Set a recovery action for an installed service
Help Options:
-h, --help Show this help message
[set command options]
-v, --verbose Verbose output
-e, --exit-code= Exit code to handle by this action.
-a, --action= Action to take if an error occurred. One of
[run-restart|none|restart|run]
-d, --delay= Delay restart of the program in seconds. (default: 0)
-r, --max-restart= Maximum restarts of the service within the specified
time span. Zero means unlimited restarts. (default: 0)
-c, --reset-timer= Specify the duration in seconds after which the
restart counter will be cleared. (default: 0)
-x, --exec= Specify the program to run if an error occurred.
[set command arguments]
SERVICE_NAME: Name of the service to set a recovery action.
ARGUMENTS: Arguments for the program to run if an error
occurred. Use '--' after SERVICE_NAME to specify
arguments starting with '-'.
Usage:
cerberus_64.exe [OPTIONS] recovery del [del-OPTIONS] SERVICE_NAME EXIT_CODE
Deletes a recovery action for an installed service
Help Options:
-h, --help Show this help message
[del command options]
-v, --verbose Verbose output
[del command arguments]
SERVICE_NAME: Name of the service to delete a recovery action.
EXIT_CODE: Exit code for which the recovery action should be
deleted.
Example
This is a minimal example:
cerberus_64.exe install -x "C:\Windows\notepad.exe" -n "MySuperService"
Caveat: The cerberus_64.exe must not be moved after installation of a service, otherwise the service won't work anymore.
Build
Requirments:
- Go >= 1.13 https://golang.org/
- GoVersionInfo https://github.com/josephspurrier/goversioninfo
Change into the cmd directory and run the following command:
C:\repo\cerberus\cmd> build.bat
# Packages
No description provided by the author
# Functions
InstallService installs a windows service with the given configuration.
LoadServiceCfg loads a service configuration for a given service from the cerberus service db.
LoadServicesCfg loads all configured services.
RemoveService removes the service with the given name.
RemoveServiceCfg removes the service configuration form the cerberus service db.
RunService runs the service with the given name.
UpdateService updates a cerberus service with the given configuration.
# Constants
AutoDelayedStartType configures the service to startup automatically with delay.
AutoStartType configures the service to startup automatically.
Signals to send to a process to gracefully terminate a process.
DisabledStartType disables the service.
ErrGeneric indicates a general error.
ErrInstallService indicates error while installing a service.
ErrInvalidConfiguration indicates error while validating service configuration.
ErrLoadServiceCfg indicates error while loading the service configuration.
ErrRemoveService indicates error while removing a service.
ErrRunService indicates error while running a service.
ErrSaveServiceCfg indicates error while saving the service configuration.
ErrSCMConnect indicates a failure while connecting to the SCM.
ErrTimeout indicates an action run into a timeout.
ErrUpdateService indicates error while updating a service.
ManualStartType configures the service for manual startup.
NoAction is the default action and will stop the service on error.
Signals to send to a process to gracefully terminate a process.
RestartAction restarts the serivce according the specified settings.
RunAndRestartAction restarts the service and runs the specified program.
RunProgramAction will run the specified program.
Signals to send to a process to gracefully terminate a process.
Signals to send to a process to gracefully terminate a process.
# Variables
DebugLogger logs all debug information, per default ioutil.Discard is used and no output is generated.
Logger is the default logger for cerberus.
# Structs
Error is a cerberus specific error.
SvcConfig is the data required run the executable as a service.
SvcRecoveryAction defines what cerberus should do if a binary returns an error.
# Type aliases
ErrorCode cerberus unique error codes.
RecoveryAction defines what happens if a binary exits with error.
StartType configures the startup type.
StopSignal specifies a signal to send to a process if the service has to stop.