0

Replace panics with our logging framework

This commit is contained in:
Gabe Kangas 2021-10-25 00:14:42 -07:00
parent cd15661f08
commit 3f4176d8d6
7 changed files with 14 additions and 11 deletions

View File

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

View File

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

View File

@ -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.

View File

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

View File

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

View File

@ -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 {

View File

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