oko-server/main.go
zegkljan 862350b875 fix cmdline flags, fix initdb script
* Actually parse the command line flags.
* Remove CASCADE from drop table.
2022-01-28 00:37:22 +01:00

33 lines
913 B
Go

package main
import (
"context"
"flag"
"os"
"os/signal"
"syscall"
"cernobor.cz/oko-server/server"
"github.com/sirupsen/logrus"
)
func main() {
dbFileArg := flag.String("dbfile", "./data.sqlite3", "File that holds the server's sqlite3 database. Will be created if it does not exist. Default is \"./data.sqlite3\".")
tilepackFileArg := flag.String("tilepack", "", "File that will be sent to clients when they request a tile pack. Required.")
apkFileArg := flag.String("apk", "", "APK file with the client app. If not specified, no APK will be available (404).")
flag.Parse()
s := server.New(*dbFileArg, *tilepackFileArg, *apkFileArg)
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT)
ctx, cancel := context.WithCancel(context.Background())
go func() {
sig := <-sigs
logrus.Warnf("Received signal: %s", sig)
cancel()
}()
s.Run(ctx)
}