lightningtipbot/main.go
LightningTipBot 1e5f7b1169
Skip duplicate edits (#245)
* speed up tx lock

* yolo master

* skip duplicate edit

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
2021-12-26 16:46:04 +01:00

49 lines
1.3 KiB
Go

package main
import (
"net/http"
"runtime/debug"
"github.com/LightningTipBot/LightningTipBot/internal/runtime/mutex"
"github.com/gorilla/mux"
_ "net/http/pprof"
"github.com/LightningTipBot/LightningTipBot/internal/lnbits/webhook"
"github.com/LightningTipBot/LightningTipBot/internal/lnurl"
"github.com/LightningTipBot/LightningTipBot/internal/price"
"github.com/LightningTipBot/LightningTipBot/internal/telegram"
log "github.com/sirupsen/logrus"
)
// setLogger will initialize the log format
func setLogger() {
log.SetLevel(log.TraceLevel)
customFormatter := new(log.TextFormatter)
customFormatter.TimestampFormat = "2006-01-02 15:04:05"
customFormatter.FullTimestamp = true
log.SetFormatter(customFormatter)
}
func main() {
// set logger
setLogger()
router := mux.NewRouter()
router.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux)
router.Handle("/mutex", http.HandlerFunc(mutex.ServeHTTP))
router.Handle("/mutex/unlock/{id}", http.HandlerFunc(mutex.UnlockHTTP))
go http.ListenAndServe("0.0.0.0:6060", router)
defer withRecovery()
bot := telegram.NewBot()
webhook.NewServer(&bot)
lnurl.NewServer(&bot)
price.NewPriceWatcher().Start()
bot.Start()
}
func withRecovery() {
if r := recover(); r != nil {
log.Errorln("Recovered panic: ", r)
debug.PrintStack()
}
}