2
0
mirror of https://github.com/namecoin/ncdns synced 2024-10-31 09:20:31 +00:00
ncdns/main.go

50 lines
1.0 KiB
Go
Raw Normal View History

2014-10-22 15:14:16 +00:00
package main
2014-11-13 10:55:51 +00:00
2014-10-22 15:14:16 +00:00
import "github.com/hlandau/degoutils/config"
import "github.com/hlandau/degoutils/service"
2014-10-22 15:14:16 +00:00
import "github.com/hlandau/ncdns/server"
2014-11-14 09:40:46 +00:00
import "path/filepath"
2014-10-22 15:14:16 +00:00
func main() {
2014-11-13 10:55:51 +00:00
cfg := server.ServerConfig{}
config := config.Configurator{
ProgramName: "ncdns",
2014-11-14 09:40:46 +00:00
ConfigFilePaths: []string{"$BIN/../etc/ncdns.conf", "/etc/ncdns/ncdns.conf"},
2014-11-13 10:55:51 +00:00
}
config.ParseFatal(&cfg)
2014-11-11 10:35:48 +00:00
2014-11-14 09:40:46 +00:00
// We use the configPath to resolve paths relative to the config file.
cfg.ConfigDir = filepath.Dir(config.ConfigFilePath())
service.Main(&service.Info{
2014-11-25 13:50:51 +00:00
Name: "ncdns",
Description: "Namecoin to DNS Daemon",
2014-11-15 08:52:14 +00:00
DefaultChroot: service.EmptyChrootPath,
RunFunc: func(smgr service.Manager) error {
s, err := server.NewServer(&cfg)
if err != nil {
return err
}
err = s.Start()
if err != nil {
return err
}
2014-11-15 08:52:14 +00:00
err = smgr.DropPrivileges()
if err != nil {
return err
}
smgr.SetStarted()
2014-11-14 09:40:46 +00:00
smgr.SetStatus("ncdns: running ok")
<-smgr.StopChan()
return nil
},
})
2014-10-22 15:14:16 +00:00
}
2014-11-11 10:35:48 +00:00
// © 2014 Hugo Landau <hlandau@devever.net> GPLv3 or later