hnctl prints line breaks after errors

This commit is contained in:
Sasha Koshka 2023-06-01 01:01:08 -04:00
parent 4e58df9c9b
commit e8349360cc
1 changed files with 9 additions and 9 deletions

View File

@ -60,19 +60,19 @@ func execStart (service string) {
pid, err := spawn.PidOf(fullName)
if err == nil && spawn.Running(pid) {
cli.Sayf("service is already running")
cli.Sayf("service is already running\n")
return
}
uid, gid, err := spawn.LookupUID(fullName)
if err != nil {
cli.Sayf("cannot start service: %v", err)
cli.Sayf("cannot start service: %v\n", err)
os.Exit(1)
}
path, err := exec.LookPath(fullName)
if err != nil {
cli.Sayf("cannot start service: %v", err)
cli.Sayf("cannot start service: %v\n", err)
os.Exit(1)
}
@ -80,7 +80,7 @@ func execStart (service string) {
env := append(os.Environ(), "HNAKRA_LOG_DIR=" + logDir)
err = ensureLogDir(logDir, int(uid), int(gid))
if err != nil {
cli.Sayf("cannot start service: %v", err)
cli.Sayf("cannot start service: %v\n", err)
os.Exit(1)
}
@ -88,14 +88,14 @@ func execStart (service string) {
// to it
err = ensurePidFile(spawn.PidFile(fullName), int(uid), int(gid))
if err != nil {
cli.Sayf("cannot start service: %v", err)
cli.Sayf("cannot start service: %v\n", err)
os.Exit(1)
}
// spawn the service
pid, err = spawn.Spawn(path, uid, gid, env)
if err != nil {
cli.Sayf("cannot start service: %v", err)
cli.Sayf("cannot start service: %v\n", err)
os.Exit(1)
}
@ -108,19 +108,19 @@ func execStop (service string) {
pid, err := spawn.PidOf(fullName)
if err != nil || !spawn.Running(pid) {
cli.Sayf("service is not running")
cli.Sayf("service is not running\n")
return
}
process, err := os.FindProcess(pid)
if err != nil {
cli.Sayf("service is not running")
cli.Sayf("service is not running\n")
return
}
err = spawn.KillAndWait(process, 16 * time.Second)
if err != nil {
cli.Sayf("could not stop service: %v", err)
cli.Sayf("could not stop service: %v\n", err)
os.Exit(1)
}
}