mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2025-12-11 06:44:58 +00:00
cleaner output and ctrl-c
This commit is contained in:
22
main.go
22
main.go
@@ -15,8 +15,28 @@ limitations under the License.
|
||||
*/
|
||||
package main
|
||||
|
||||
import "github.com/cupcakearmy/autorestic/cmd"
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/cupcakearmy/autorestic/cmd"
|
||||
"github.com/cupcakearmy/autorestic/internal/lock"
|
||||
)
|
||||
|
||||
func handleCtrlC() {
|
||||
c := make(chan os.Signal)
|
||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
sig := <-c
|
||||
fmt.Println("Signal:", sig)
|
||||
lock.Unlock()
|
||||
os.Exit(0)
|
||||
}()
|
||||
}
|
||||
|
||||
func main() {
|
||||
handleCtrlC()
|
||||
cmd.Execute()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user