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.
riffraff/main.go

37 lines
892 B

5 years ago
package main
import (
"flag"
"fmt"
"log"
"net/http"
"github.com/adamveld12/riffraff/internal"
"github.com/gobuffalo/packr"
)
func main() {
port := flag.Int("port", 80, "port to listen on")
bindAddr := flag.String("bind", "127.0.0.1", "interface to bind to")
Squashed commit of the following: commit aa1027292e91b55766e952da34e26a8d7338a64f Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Tue Nov 19 09:53:21 2019 -0600 tweak into text commit 8b1945df7e840e54a8472e6b75ec5293bbd89ac4 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Tue Nov 19 09:31:35 2019 -0600 make -accessLog flag actually work commit 685a2896abd15b560866b8f946b9296e5100c447 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Tue Nov 19 09:31:07 2019 -0600 update formatting with gofmt, and fix lint errors commit 6a74c5f9f06a442257d28c7aa98e09393d995b03 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Tue Nov 19 08:24:58 2019 -0600 add data generation, version tagging vars to build process commit 5822152537ae812e4bceb98dc5d202906d301749 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Tue Nov 19 07:49:22 2019 -0600 add saving shortcuts to local db file commit cb21c3a49844f5aa584007fa16d32a66ab302c32 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Mon Nov 18 23:51:21 2019 -0600 added bind address flag commit 547bec5eb7f8b98f775a7ae905f80c0328264cf6 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Mon Nov 18 22:37:06 2019 -0600 refactor shortcut code to be a little nicer commit 15667ca70456d22c4dead0a4c5740876b91ec712 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Mon Nov 18 00:48:06 2019 -0600 add some stubs for saving user updates to a data file commit 4e74fd955b941a8a054160b8416e92fd75550a06 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Mon Nov 18 00:30:29 2019 -0600 added config file loading, fixed bug with search shortcuts
5 years ago
dbPath := flag.String("data", "./data.json", "path to save shortcut database")
5 years ago
enableAccessLogging := flag.Bool("accesslog", true, "Enable access logging")
flag.Parse()
box := packr.NewBox("./internal/templates")
tp := internal.TemplateRenderer{FS: box}
Squashed commit of the following: commit aa1027292e91b55766e952da34e26a8d7338a64f Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Tue Nov 19 09:53:21 2019 -0600 tweak into text commit 8b1945df7e840e54a8472e6b75ec5293bbd89ac4 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Tue Nov 19 09:31:35 2019 -0600 make -accessLog flag actually work commit 685a2896abd15b560866b8f946b9296e5100c447 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Tue Nov 19 09:31:07 2019 -0600 update formatting with gofmt, and fix lint errors commit 6a74c5f9f06a442257d28c7aa98e09393d995b03 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Tue Nov 19 08:24:58 2019 -0600 add data generation, version tagging vars to build process commit 5822152537ae812e4bceb98dc5d202906d301749 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Tue Nov 19 07:49:22 2019 -0600 add saving shortcuts to local db file commit cb21c3a49844f5aa584007fa16d32a66ab302c32 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Mon Nov 18 23:51:21 2019 -0600 added bind address flag commit 547bec5eb7f8b98f775a7ae905f80c0328264cf6 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Mon Nov 18 22:37:06 2019 -0600 refactor shortcut code to be a little nicer commit 15667ca70456d22c4dead0a4c5740876b91ec712 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Mon Nov 18 00:48:06 2019 -0600 add some stubs for saving user updates to a data file commit 4e74fd955b941a8a054160b8416e92fd75550a06 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Mon Nov 18 00:30:29 2019 -0600 added config file loading, fixed bug with search shortcuts
5 years ago
ss := &internal.ShortcutStore{Path: *dbPath}
if err := ss.Init(); err != nil {
log.Fatalf("could not access database file: %v", err)
}
server := internal.NewServer(tp, ss, *enableAccessLogging)
5 years ago
log.SetPrefix("[INFO] ")
Squashed commit of the following: commit aa1027292e91b55766e952da34e26a8d7338a64f Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Tue Nov 19 09:53:21 2019 -0600 tweak into text commit 8b1945df7e840e54a8472e6b75ec5293bbd89ac4 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Tue Nov 19 09:31:35 2019 -0600 make -accessLog flag actually work commit 685a2896abd15b560866b8f946b9296e5100c447 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Tue Nov 19 09:31:07 2019 -0600 update formatting with gofmt, and fix lint errors commit 6a74c5f9f06a442257d28c7aa98e09393d995b03 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Tue Nov 19 08:24:58 2019 -0600 add data generation, version tagging vars to build process commit 5822152537ae812e4bceb98dc5d202906d301749 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Tue Nov 19 07:49:22 2019 -0600 add saving shortcuts to local db file commit cb21c3a49844f5aa584007fa16d32a66ab302c32 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Mon Nov 18 23:51:21 2019 -0600 added bind address flag commit 547bec5eb7f8b98f775a7ae905f80c0328264cf6 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Mon Nov 18 22:37:06 2019 -0600 refactor shortcut code to be a little nicer commit 15667ca70456d22c4dead0a4c5740876b91ec712 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Mon Nov 18 00:48:06 2019 -0600 add some stubs for saving user updates to a data file commit 4e74fd955b941a8a054160b8416e92fd75550a06 Author: Adam Veldhousen <adam.veldhousen@liveauctioneers.com> Date: Mon Nov 18 00:30:29 2019 -0600 added config file loading, fixed bug with search shortcuts
5 years ago
addr := fmt.Sprintf("%s:%d", *bindAddr, *port)
5 years ago
log.Printf("Listening @ %s", addr)
log.Fatal(http.ListenAndServe(addr, server))
}