diff --git a/README.md b/README.md index f5edeea..68b015d 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Service Shark is: - easy to use - lightweight (~2 MB) - has zero runtime dependencies (no .NET Framework, Java, ...) +- [12factor/config](https://12factor.net/config) support - written in [golang](https://golang.org/) Service Shark is not: @@ -26,11 +27,6 @@ Service Shark is not: https://github.com/matthiasng/service-shark/releases/latest ``` -#### Scoop -``` -#todo setup scoop bucket + goreleaser -``` - ### Compiling from source ``` git clone https://github.com/matthiasng/service-shark.git @@ -40,4 +36,25 @@ go build -o service-shark.exe main.go ## Usage -#todo +``` + -cmd string + Command [required] + -logdir string + Log directory. + File name: {name}_YYYY-MM-DD_HH-MM-SS (default "./log") + -name string + Service name [required] + -workdir string + Working directory [required] + -- (terminator) + Pass all arguments after the terminator "--" to command. + Bind argument to environment variable with "env:{VAR_NAME}". +``` + +Exampe +``` +service-shark.exe -name MyService -workdir C:/MyService -cmd java -- -jar MyProg.jar -Xmx1G -myArg "env:TEST_VALUE" +``` +Service Shark will run ``java`` with ``-jar MyProg.jar -Xmx1G -myArg "123"`` from ``C:/MyService``. + +See [example/test-example-service.ps1](./example/test-example-service.ps1) for a complate example. diff --git a/command/host.go b/command/host.go index 9a68f33..63ff1b4 100644 --- a/command/host.go +++ b/command/host.go @@ -26,7 +26,7 @@ func (h *Host) init(env service.Environment) error { return err } - logFileName := fmt.Sprintf("%s_%s.log", h.Name(), time.Now().Format("02-01-2006_15-04-05")) + logFileName := fmt.Sprintf("%s_%s.log", h.Name(), time.Now().Format("2006-01-02-_15-04-05")) logFilePath := path.Join(h.Arguments.LogDirectory, logFileName) logFile, err := os.Create(logFilePath) diff --git a/main.go b/main.go index b7f4d3a..fae2978 100644 --- a/main.go +++ b/main.go @@ -15,14 +15,22 @@ var arguments = cli.Arguments{} func init() { flag.CommandLine.Usage = func() { - fmt.Println("Usage of Service Shark:") + fmt.Println("Service Shark:") + fmt.Println(" Host any executable as a Windows service.") + fmt.Println("Usage:") flag.PrintDefaults() + fmt.Println(" -- (terminator)") + fmt.Println(` Pass all arguments after the terminator "--" to command.`) + fmt.Println(` Bind argument to environment variable with "env:{VAR_NAME}".`) + fmt.Println("Example:") + fmt.Println(` service-shark.exe ... -cmd java -- -jar test.jar -Xmx1G -myArg "env:MY_VALUE"`) + fmt.Println(` => java -jar test.jar -Xmx1G -myArg "my env value"`) } flag.StringVar(&arguments.Name, "name", "", "Service name [required]") flag.StringVar(&arguments.WorkingDirectory, "workdir", "", "Working directory [required]") - flag.StringVar(&arguments.LogDirectory, "logdir", "./log", "Log directory. Absolute path or relative to working directory.") - flag.StringVar(&arguments.Command, "cmd", "", "Command [required]") + flag.StringVar(&arguments.LogDirectory, "logdir", "./log", "Log directory.\nFile name: {name}_YYYY-MM-DD_HH-MM-SS") + flag.StringVar(&arguments.Command, "cmd", "", `Command [required]`) flag.Parse() }