Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

[feature] dump session json on signal #212

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions core/dump_nix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// +build linux darwin

package core

import (
"os"
"os/signal"
"syscall"
)

func DumpSessionOnSig(sess *Session) {
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGUSR1)
for range sigChan {
sess.Lock()
err := sess.SaveToFile("aquatone_session.json")
if err != nil {
sess.Out.Error("Failed to write session file")
sess.Out.Debug("Err: %s", err.Error())
}
sess.Unlock()
}
}
7 changes: 7 additions & 0 deletions core/dump_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// +build windows

package core

func DumpSessionOnSig(sess *Session) {
// not supported
}
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ func main() {
os.Exit(0)
}

go core.DumpSessionOnSig(sess)

agents.NewTCPPortScanner().Register(sess)
agents.NewURLPublisher().Register(sess)
agents.NewURLRequester().Register(sess)
Expand Down