mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
* When stopping, close the database This patch is likely to cause errornous behavior in the application. This is due to the fact that the application doesn't gracefully shut down, but is forcefully terminated. However, the purpose is to uncover what needs to be done, to make it a more graceful shutdown.
38 lines
754 B
Go
38 lines
754 B
Go
//go:generate go run -mod=vendor github.com/99designs/gqlgen
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"os/signal"
|
|
"runtime/pprof"
|
|
"syscall"
|
|
|
|
"github.com/stashapp/stash/pkg/api"
|
|
"github.com/stashapp/stash/pkg/logger"
|
|
"github.com/stashapp/stash/pkg/manager"
|
|
|
|
_ "github.com/golang-migrate/migrate/v4/database/sqlite3"
|
|
_ "github.com/golang-migrate/migrate/v4/source/file"
|
|
)
|
|
|
|
func main() {
|
|
manager.Initialize()
|
|
api.Start()
|
|
|
|
// stop any profiling at exit
|
|
defer pprof.StopCPUProfile()
|
|
blockForever()
|
|
|
|
err := manager.GetInstance().Shutdown()
|
|
if err != nil {
|
|
logger.Errorf("Error when closing: %s", err)
|
|
}
|
|
}
|
|
|
|
func blockForever() {
|
|
// handle signals
|
|
signals := make(chan os.Signal, 1)
|
|
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
|
|
|
|
<-signals
|
|
}
|