cleaner output and ctrl-c

This commit is contained in:
2021-04-12 16:15:17 +02:00
parent 640b60c47f
commit 3ccaee4066
10 changed files with 118 additions and 86 deletions

22
main.go
View File

@@ -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()
}