Skip to content

Commit

Permalink
fix: crash in case of failure to bind (fix #25)
Browse files Browse the repository at this point in the history
  • Loading branch information
muety committed Jan 7, 2021
1 parent ac9137e commit 94fe864
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
3 changes: 2 additions & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ CMD_ARGS="-token $APP_TOKEN \
-address 0.0.0.0 \
-dataDir /srv/data \
-mode $APP_MODE \
-rateLimit $APP_RATE_LIMIT"
-rateLimit $APP_RATE_LIMIT \
-disableIPv6"

if [[ "$APP_TOKEN" == "" ]]; then
echo "Token missing. Please provide one."
Expand Down
24 changes: 20 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,35 @@ func listen() {

if botConfig.UseHTTPS {
fmt.Printf("Listening for HTTPS on %s.\n", s.Addr)
go s.ListenAndServeTLS(botConfig.CertPath, botConfig.KeyPath)
go func() {
if err := s.ListenAndServeTLS(botConfig.CertPath, botConfig.KeyPath); err != nil {
log.Fatalln(err)
}
}()

if s6 != nil {
fmt.Printf("Listening for HTTPS on %s.\n", s6.Addr)
go s6.ListenAndServeTLS(botConfig.CertPath, botConfig.KeyPath)
go func() {
if err := s6.ListenAndServeTLS(botConfig.CertPath, botConfig.KeyPath); err != nil {
log.Fatalln(err)
}
}()
}
} else {
fmt.Printf("Listening for HTTP on %s.\n", s.Addr)
go s.ListenAndServe()
go func() {
if err := s.ListenAndServe(); err != nil {
log.Fatalln(err)
}
}()

if s6 != nil {
fmt.Printf("Listening for HTTP on %s.\n", s6.Addr)
go s6.ListenAndServe()
go func() {
if err := s6.ListenAndServe(); err != nil {
log.Fatalln(err)
}
}()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.2
2.2.3

0 comments on commit 94fe864

Please sign in to comment.