mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 03:24:40 -07:00
Update service and syslog code to use variable instead of constant
for the process name and service name. This allows the reuse of this code in NATS Streaming Server by invoking the new setters to change the service and process names. Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
@@ -35,7 +35,7 @@ var (
|
||||
|
||||
const (
|
||||
// VERSION is the current version for the server.
|
||||
VERSION = "1.2.0"
|
||||
VERSION = "1.3.0"
|
||||
|
||||
// PROTO is the currently supported protocol.
|
||||
// 0 was the original
|
||||
|
||||
@@ -22,12 +22,18 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
serviceName = "gnatsd"
|
||||
reopenLogCode = 128
|
||||
reopenLogCmd = svc.Cmd(reopenLogCode)
|
||||
acceptReopenLog = svc.Accepted(reopenLogCode)
|
||||
)
|
||||
|
||||
var serviceName = "gnatsd"
|
||||
|
||||
// SetServiceName allows setting a different service name
|
||||
func SetServiceName(name string) {
|
||||
serviceName = name
|
||||
}
|
||||
|
||||
// winServiceWrapper implements the svc.Handler interface for implementing
|
||||
// gnatsd as a Windows service.
|
||||
type winServiceWrapper struct {
|
||||
|
||||
@@ -26,7 +26,12 @@ import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
const processName = "gnatsd"
|
||||
var processName = "gnatsd"
|
||||
|
||||
// SetProcessName allows to change the expected name of the process.
|
||||
func SetProcessName(name string) {
|
||||
processName = name
|
||||
}
|
||||
|
||||
// Signal Handling
|
||||
func (s *Server) handleSignals() {
|
||||
@@ -76,10 +81,10 @@ func ProcessSignal(command Command, pidStr string) error {
|
||||
return err
|
||||
}
|
||||
if len(pids) == 0 {
|
||||
return errors.New("no gnatsd processes running")
|
||||
return fmt.Errorf("no %s processes running", processName)
|
||||
}
|
||||
if len(pids) > 1 {
|
||||
errStr := "multiple gnatsd processes running:\n"
|
||||
errStr := fmt.Sprintf("multiple %s processes running:\n", processName)
|
||||
prefix := ""
|
||||
for _, p := range pids {
|
||||
errStr += fmt.Sprintf("%s%d", prefix, p)
|
||||
|
||||
Reference in New Issue
Block a user