Gemini server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.1 KiB

2 years ago
package main
import (
"flag"
"log"
"os"
"os/signal"
2 years ago
"path"
"syscall"
2 years ago
)
func init() {
log.SetOutput(os.Stdout)
}
var quiet bool
var debug bool
2 years ago
func main() {
log.SetFlags(0)
2 years ago
configFile := flag.String("config", "", "path to configuration file")
flag.BoolVar(&quiet, "quiet", false, "do not print access log")
flag.BoolVar(&debug, "debug", false, "print debug information")
2 years ago
flag.Parse()
if *configFile == "" {
homedir, err := os.UserHomeDir()
if err == nil && homedir != "" {
*configFile = path.Join(homedir, ".config", "twins", "config.yaml")
}
}
sig := make(chan os.Signal, 1)
signal.Notify(sig, syscall.SIGHUP)
go func() {
for {
<-sig
err := readconfig(*configFile)
if err != nil {
log.Fatalf("failed to reload configuration file at %s: %v", *configFile, err)
}
log.Println("configuration reloaded successfully")
}
}()
2 years ago
err := readconfig(*configFile)
if err != nil {
2 years ago
log.Fatalf("failed to read configuration file at %s: %v\nSee CONFIGURATION.md for information on configuring twins", *configFile, err)
}
listen(config.Listen)
2 years ago
}