go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/graceful/notify.go (about) 1 /* 2 3 Copyright (c) 2023 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package graceful 9 10 import ( 11 "os" 12 "os/signal" 13 ) 14 15 // SignalNotify returns a channel that listens for a given set of os signals. 16 func SignalNotify(signals ...os.Signal) chan os.Signal { 17 return SignalNotifyWithCapacity(1, signals...) 18 } 19 20 // SignalNotifyWithCapacity returns a channel with a given capacity 21 // that listens for a given set of os signals. 22 func SignalNotifyWithCapacity(capacity int, signals ...os.Signal) chan os.Signal { 23 terminateSignal := make(chan os.Signal, capacity) 24 signal.Notify(terminateSignal, signals...) 25 return terminateSignal 26 }