From 29dfa982bceaea0d82037f47572648309df06056 Mon Sep 17 00:00:00 2001 From: Aldino Kemal Date: Mon, 21 Nov 2022 23:30:19 +0700 Subject: [PATCH] feat: add auto reconnect --- src/cmd/root.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cmd/root.go b/src/cmd/root.go index 7764bc4..cbef10a 100644 --- a/src/cmd/root.go +++ b/src/cmd/root.go @@ -17,8 +17,10 @@ import ( "github.com/markbates/pkger" _ "github.com/mattn/go-sqlite3" "log" + "net/http" "os" "strings" + "time" "github.com/spf13/cobra" ) @@ -108,6 +110,11 @@ func runRest(cmd *cobra.Command, args []string) { }) }) + // Set auto reconnect to whatsapp server after booting + go func() { + time.Sleep(2 * time.Second) + _, _ = http.Get(fmt.Sprintf("http://localhost:%s/app/reconnect", config.AppPort)) + }() err = app.Listen(":" + config.AppPort) if err != nil { log.Fatalln("Failed to start: ", err.Error())