-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make process and czar client graceful exit
- Loading branch information
Showing
7 changed files
with
98 additions
and
31 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
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,3 @@ | ||
# Gracefulexit | ||
|
||
A graceful exit (or graceful handling) is a simple programming idiom[citation needed] wherein a program detects a serious error condition and "exits gracefully" in a controlled manner as a result. Often the program prints a descriptive error message to a terminal or log as part of the graceful exit. |
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,22 @@ | ||
// A graceful exit (or graceful handling) is a simple programming idiom[citation needed] wherein a program detects a | ||
// serious error condition and "exits gracefully" in a controlled manner as a result. Often the program prints a | ||
// descriptive error message to a terminal or log as part of the graceful exit. | ||
package gracefulexit | ||
|
||
import ( | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
) | ||
|
||
// Chan create a channel for os.Signal. | ||
func Chan() chan os.Signal { | ||
buffer := make(chan os.Signal, 1) | ||
signal.Notify(buffer, syscall.SIGINT, syscall.SIGTERM) | ||
return buffer | ||
} | ||
|
||
// Wait for a signal. | ||
func Wait() { | ||
<-Chan() | ||
} |
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,18 @@ | ||
package gracefulexit | ||
|
||
import ( | ||
"os" | ||
"os/signal" | ||
) | ||
|
||
// Chan create a channel for os.Signal. | ||
func Chan() chan os.Signal { | ||
buffer := make(chan os.Signal, 1) | ||
signal.Notify(buffer, os.Interrupt) | ||
return buffer | ||
} | ||
|
||
// Wait for a signal. | ||
func Wait() { | ||
<-Chan() | ||
} |
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