Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38a9383c24 |
No files matched your search
@@ -93,10 +93,10 @@ An AS number, prefix or mask length that does not parse answers 400, as does a
|
|||||||
mask length out of range for its IP version. An AS the database does not hold,
|
mask length out of range for its IP version. An AS the database does not hold,
|
||||||
or a prefix with no live route, answers 404. The HTML pages give these errors as
|
or a prefix with no live route, answers 404. The HTML pages give these errors as
|
||||||
plain text. Under `/api/v1` and `/ip/`, a path no route matches answers 404 with
|
plain text. Under `/api/v1` and `/ip/`, a path no route matches answers 404 with
|
||||||
the message `Not found`, and `POST`, `PUT`, `PATCH`, `DELETE`, `OPTIONS`,
|
the message `Not found`, and a method other than `GET` and `HEAD` answers 405
|
||||||
`TRACE` or `CONNECT` answers 405 with `Method not allowed`. A 500 answer says
|
with `Method not allowed`. A 500 answer says only `Internal server error`, and a
|
||||||
only `Internal server error`, and a host name that does not resolve only
|
host name that does not resolve only `could not resolve host name`; the detail
|
||||||
`could not resolve host name`; the detail goes to the log.
|
goes to the log.
|
||||||
|
|
||||||
Every answer carries `Strict-Transport-Security`, `Content-Security-Policy`,
|
Every answer carries `Strict-Transport-Security`, `Content-Security-Policy`,
|
||||||
`X-Frame-Options`, `X-Content-Type-Options`, `Referrer-Policy` and
|
`X-Frame-Options`, `X-Content-Type-Options`, `Referrer-Policy` and
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ package routewatch
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.eeqj.de/sneak/routewatch/internal/logger"
|
"git.eeqj.de/sneak/routewatch/internal/logger"
|
||||||
@@ -60,10 +62,10 @@ func logDebugStats(logger *logger.Logger) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CLIEntry is the main entry point for the routewatch command-line interface.
|
// CLIEntry is the main entry point for the routewatch command-line interface.
|
||||||
// It initializes the application using the fx dependency injection framework
|
// It initializes the application using the fx dependency injection framework,
|
||||||
// and starts the RouteWatch service. It blocks until fx receives SIGINT or
|
// sets up signal handling for graceful shutdown, and starts the RouteWatch
|
||||||
// SIGTERM or RouteWatch stops on an error; fx then runs the stop hook and sets
|
// service. This function blocks until the application receives a shutdown
|
||||||
// the exit code.
|
// signal or encounters a fatal error.
|
||||||
func CLIEntry() {
|
func CLIEntry() {
|
||||||
app := fx.New(
|
app := fx.New(
|
||||||
fx.Options(getModule()...),
|
fx.Options(getModule()...),
|
||||||
@@ -79,6 +81,20 @@ func CLIEntry() {
|
|||||||
// Start debug stats logging
|
// Start debug stats logging
|
||||||
go logDebugStats(logger)
|
go logDebugStats(logger)
|
||||||
|
|
||||||
|
// Handle shutdown signals
|
||||||
|
sigCh := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
<-sigCh
|
||||||
|
logger.Info("Received shutdown signal")
|
||||||
|
|
||||||
|
err := shutdowner.Shutdown()
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("Failed to shutdown gracefully", "error", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
err := rw.Run(ctx)
|
err := rw.Run(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in new issue
Block a user