Skip to content

matthiasng/service-shark

Repository files navigation

Service Shark

GitHub GitHub release (latest SemVer) build codecov Go Report Card

Service Shark can be used to to host any executable as a Windows service.

Service Shark is:

  • easy to use
  • lightweight (~2 MB)
  • has zero runtime dependencies (no .NET Framework, Java, ...)
  • 12factor/config support
  • written in golang

Service Shark is not:

  • a service manager. There are already ways to manage Windows services (powershell, cmd, NSSM)

Installation

Pre-compiled binary

Download from github

https://github.com/matthiasng/service-shark/releases/latest

Compiling from source

git clone https://github.com/matthiasng/service-shark.git
cd service-shark
go build -o service-shark.exe main.go

Usage

  -name string
        Service name [required]
  -workdir string
        Working directory (default "./")
  -logdir string
        Log directory.
        File name: {name}_YYYY-MM-DD_HH-MM-SS (default "./log")
  -cmd string
        Command [required]
  -version
        Print version and exit
  -- (terminator)
        Pass all arguments after the terminator "--" to the command.
        Bind argument to environment variable with "env:{VAR_NAME}".

Example

service-shark.exe -name MyService -workdir C:/MyService -cmd java -- -jar MyProg.jar -Xmx1G -myArg "env:MY_ENV_VALUE"

Service Shark will run java with -jar MyProg.jar -Xmx1G -myArg "123" from C:/MyService (MY_ENV_VALUE is 123).

See example/test-example-service.ps1 for a complete example.