1 Commits

Author SHA1 Message Date
Timmy Welch
58016c6889 Fix output on startup and TERM signal 2026-01-10 14:06:19 -08:00

View File

@@ -156,6 +156,9 @@ func main() {
flag.Parse() flag.Parse()
sshCommand := flag.Args() sshCommand := flag.Args()
if cli.Verbose {
logger.SetLevel(logrus.DebugLevel)
}
cfgFile := ExpandPath(cli.Config) cfgFile := ExpandPath(cli.Config)
cfgFile, err = filepath.Abs(cfgFile) cfgFile, err = filepath.Abs(cfgFile)
@@ -175,7 +178,7 @@ func main() {
logger.Println("Launching agent") logger.Println("Launching agent")
main2(cli, c) main2(cli, c)
} else { } else {
logger.Println("Attempting to start daemon") logger.Debug("Attempting to start daemon")
var nullFile *os.File var nullFile *os.File
nullFile, err = os.Open(os.DevNull) nullFile, err = os.Open(os.DevNull)
if err != nil { if err != nil {
@@ -200,6 +203,7 @@ func main() {
panic(err) panic(err)
} }
nullFile.Close() nullFile.Close()
logger.Debugf("Agent started in the background check %s for logs", getLogDir())
} }
if len(sshCommand) > 1 && filepath.Base(sshCommand[0]) == "ssh" { if len(sshCommand) > 1 && filepath.Base(sshCommand[0]) == "ssh" {
syscall.Exec(sshCommand[0], sshCommand, os.Environ()) syscall.Exec(sshCommand[0], sshCommand, os.Environ())
@@ -358,8 +362,9 @@ func launchAgent(c *config.SSHrimp, listener net.Listener) error {
osSignals := make(chan os.Signal, 10) osSignals := make(chan os.Signal, 10)
signal.Notify(osSignals, sigExit...) signal.Notify(osSignals, sigExit...)
go func() { go func() {
<-osSignals sig := <-osSignals
listener.Close() log.Infof("Recieved signal %v: closing", sig)
os.Exit(0)
}() }()
log.Traceln("Starting main loop") log.Traceln("Starting main loop")