From 3f4176d8d6663fc8812f813b3f6620eb3870c128 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Mon, 25 Oct 2021 00:14:42 -0700 Subject: [PATCH] Replace panics with our logging framework --- core/chat/concurrentConnections.go | 4 ++-- core/chat/concurrentConnections_freebsd.go | 4 ++-- core/chat/utils.go | 7 +++++-- core/data/data.go | 2 +- core/storageproviders/s3Storage.go | 2 +- core/transcoder/transcoder.go | 2 +- utils/utils.go | 4 ++-- 7 files changed, 14 insertions(+), 11 deletions(-) diff --git a/core/chat/concurrentConnections.go b/core/chat/concurrentConnections.go index ab3912a30..0a968b549 100644 --- a/core/chat/concurrentConnections.go +++ b/core/chat/concurrentConnections.go @@ -12,13 +12,13 @@ import ( func setSystemConcurrentConnectionLimit(limit int64) { var rLimit syscall.Rlimit if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit); err != nil { - panic(err) + log.Fatalln(err) } originalLimit := rLimit.Cur rLimit.Cur = uint64(limit) if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit); err != nil { - panic(err) + log.Fatalln(err) } log.Traceln("Max process connection count changed from system limit of", originalLimit, "to", limit) diff --git a/core/chat/concurrentConnections_freebsd.go b/core/chat/concurrentConnections_freebsd.go index acd2091fe..abc2a8701 100644 --- a/core/chat/concurrentConnections_freebsd.go +++ b/core/chat/concurrentConnections_freebsd.go @@ -11,13 +11,13 @@ import ( func setSystemConcurrentConnectionLimit(limit int64) { var rLimit syscall.Rlimit if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit); err != nil { - panic(err) + log.Fatalln(err) } originalLimit := rLimit.Cur rLimit.Cur = int64(limit) if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit); err != nil { - panic(err) + log.Fatalln(err) } log.Traceln("Max process connection count changed from system limit of", originalLimit, "to", limit) diff --git a/core/chat/utils.go b/core/chat/utils.go index 973b8f28d..8fbebbe49 100644 --- a/core/chat/utils.go +++ b/core/chat/utils.go @@ -1,11 +1,14 @@ package chat -import "syscall" +import ( + "syscall" + log "github.com/sirupsen/logrus" +) func getMaximumConcurrentConnectionLimit() int64 { var rLimit syscall.Rlimit if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit); err != nil { - panic(err) + log.Fatalln(err) } // Return the limit to 70% of max so the machine doesn't die even if it's maxed out for some reason. diff --git a/core/data/data.go b/core/data/data.go index 7ca010800..bf5086316 100644 --- a/core/data/data.go +++ b/core/data/data.go @@ -122,7 +122,7 @@ func migrateDatabase(db *sql.DB, from, to int) error { log.Tracef("Migration step from %d to %d\n", v, v+1) migrateToSchema1(db) default: - panic("missing database migration step") + log.Fatalln("missing database migration step") } } diff --git a/core/storageproviders/s3Storage.go b/core/storageproviders/s3Storage.go index 875170c66..ec8413046 100644 --- a/core/storageproviders/s3Storage.go +++ b/core/storageproviders/s3Storage.go @@ -200,7 +200,7 @@ func (s *S3Storage) connectAWS() *session.Session { func (s *S3Storage) rewriteRemotePlaylist(filePath string) error { f, err := os.Open(filePath) // nolint if err != nil { - panic(err) + log.Fatalln(err) } p := m3u8.NewMasterPlaylist() diff --git a/core/transcoder/transcoder.go b/core/transcoder/transcoder.go index 229bddd9c..4d0d168e2 100644 --- a/core/transcoder/transcoder.go +++ b/core/transcoder/transcoder.go @@ -105,7 +105,7 @@ func (t *Transcoder) Start() { stdout, err := _commandExec.StderrPipe() if err != nil { - panic(err) + log.Fatalln(err) } if err := _commandExec.Start(); err != nil { diff --git a/utils/utils.go b/utils/utils.go index 122ae400c..c9dba2888 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -132,7 +132,7 @@ func RenderSimpleMarkdown(raw string) string { trimmed := strings.TrimSpace(raw) var buf bytes.Buffer if err := markdown.Convert([]byte(trimmed), &buf); err != nil { - panic(err) + log.Fatalln(err) } return buf.String() @@ -161,7 +161,7 @@ func RenderPageContentMarkdown(raw string) string { trimmed := strings.TrimSpace(raw) var buf bytes.Buffer if err := markdown.Convert([]byte(trimmed), &buf); err != nil { - panic(err) + log.Fatalln(err) } return strings.TrimSpace(buf.String())