-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only listen for the USR1 signals on some platforms. Fixes #157.
- Loading branch information
Showing
3 changed files
with
33 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//go:build windows | ||
|
||
package platformdep | ||
|
||
func SetupSignals(clearCacheFunction func(), printFunction func(format string, args ...interface{})) { | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//go:build !windows | ||
|
||
package platformdep | ||
|
||
import ( | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
) | ||
|
||
func SetupSignals(clearCacheFunction func(), printFunction func(format string, args ...interface{})) { | ||
// Listen for SIGUSR1 to clear the cache | ||
signals := make(chan os.Signal, 1) | ||
signal.Notify(signals, syscall.SIGUSR1) | ||
go func() { | ||
for { | ||
// Wait for a signal of the type given to signal.Notify | ||
sig := <-signals | ||
printFunction("Received %v", sig) | ||
// Launch a goroutine for clearing the cache | ||
go clearCacheFunction() | ||
} | ||
}() | ||
} |