diff --git a/README.md b/README.md index b656990..6bd7486 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ func main() { - **Trace ID Propagation**: Automatically generates a shared Trace ID for all services during startup, ensuring log correlation. - **Secure IPC**: Token-based Unix Domain Socket for `status` and `kill` commands. - **Zero Configuration PID**: Automatic PID management in the system temporary directory. +- **Embedded Log Writer**: Automatically registered log writer service with high priority (-100). ## Commands diff --git a/starter.go b/starter.go index a9eeec7..7b9cfb2 100644 --- a/starter.go +++ b/starter.go @@ -29,6 +29,7 @@ var ( // Default configuration appName = filepath.Base(os.Args[0]) appVersion = "1.0.1" + appUsage = "" // Internal state commands = make(map[string]*command) @@ -64,6 +65,9 @@ func init() { AddCommand("restart", "Restart the service", restartCmd) AddCommand("status", "Show service status", statusCmd) AddCommand("kill", "Send signal to a specific service: kill ", killCmd) + + // Auto-register log writer service with high priority + Register("log-writer", log.WriterService, -100, 0, 0) } // Register adds a service to be managed by the starter. @@ -83,6 +87,11 @@ func SetAppInfo(name, version string) { appVersion = version } +// SetUsage sets custom usage text to be displayed in help. +func SetUsage(text string) { + appUsage = text +} + // AddCommand adds a custom command. func AddCommand(name, desc string, fn func()) { commands[name] = &command{name: name, desc: desc, fn: fn} @@ -117,8 +126,11 @@ func Run() { } func showHelp() { - fmt.Printf("%s (%s)\n\nUsage:\n %s [command] [options]\n\nCommands:\n", - appName, appVersion, filepath.Base(os.Args[0])) + fmt.Printf("%s (%s)\n\n", appName, appVersion) + if appUsage != "" { + fmt.Printf("%s\n\n", appUsage) + } + fmt.Printf("Usage:\n %s [command] [options]\n\nCommands:\n", filepath.Base(os.Args[0])) var names []string for cmdName := range commands {