stash/main.go

46 lines
870 B
Go
Raw Normal View History

//go:generate go run -mod=vendor github.com/99designs/gqlgen
2019-02-09 12:30:49 +00:00
package main
import (
"embed"
"os"
"os/signal"
"runtime/pprof"
"syscall"
2019-02-14 23:42:52 +00:00
"github.com/stashapp/stash/pkg/api"
"github.com/stashapp/stash/pkg/logger"
2019-02-14 23:42:52 +00:00
"github.com/stashapp/stash/pkg/manager"
2019-02-09 12:30:49 +00:00
_ "github.com/golang-migrate/migrate/v4/database/sqlite3"
_ "github.com/golang-migrate/migrate/v4/source/file"
)
//go:embed ui/v2.5/build
var uiBox embed.FS
//go:embed ui/login
var loginUIBox embed.FS
2019-02-09 12:30:49 +00:00
func main() {
manager.Initialize()
api.Start(uiBox, loginUIBox)
// stop any profiling at exit
defer pprof.StopCPUProfile()
2019-02-11 10:49:39 +00:00
blockForever()
err := manager.GetInstance().Shutdown()
if err != nil {
logger.Errorf("Error when closing: %s", err)
}
2019-02-11 10:49:39 +00:00
}
func blockForever() {
// handle signals
signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
<-signals
2019-02-09 12:30:49 +00:00
}