Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
57 lines (47 sloc) 1.17 KB
package main
import (
func main() {
var (
cfg *config.Config
err error
// Ensure that exactly one or two arguments were supplied
// - the application itself
// - the configuration file [OPTIONAL]
// With no config file supplied, os.Environ is used instead
switch len(os.Args) {
case 1:
log.Print("loading configuration from environment")
cfg = config.LoadFromEnvironment()
case 2:
log.Printf("loading configuration from '%s'...", os.Args[1])
cfg, err = config.LoadFromDisk(os.Args[1])
if err != nil {
log.Fatalf("Usage: %s [CONFIG]", os.Args[0])
log.Printf("data path: '%s'", cfg.DataPath)
log.Printf("root path: '%s'", cfg.RootPath)
// Finally, create the server that will listen for requests
log.Print("initializing server...")
server, err := server.New(cfg)
if err != nil {
defer server.Close()
log.Println("application is running")
// Wait for SIGINT to be sent
ch := make(chan os.Signal)
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
log.Print("shutting down...")
You can’t perform that action at this time.