run on prod env
This commit is contained in:
parent
b45c66c94e
commit
fd673de247
|
@ -30,6 +30,8 @@ goose up
|
|||
## Build and run
|
||||
go build
|
||||
|
||||
edit transmet.conf to point to correct location
|
||||
|
||||
sudo cp transmet.conf /etc/init
|
||||
|
||||
sudo service transmet start
|
||||
|
|
15
main.go
15
main.go
|
@ -11,6 +11,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"flag"
|
||||
)
|
||||
|
||||
const VERSION = "0.1"
|
||||
|
@ -38,10 +39,10 @@ var (
|
|||
templates = map[string]*template.Template{}
|
||||
)
|
||||
|
||||
func loadConfig() {
|
||||
file, err := os.Open("config/local.json")
|
||||
func loadConfig(env string) {
|
||||
file, err := os.Open("config/" + env + ".json")
|
||||
if err != nil {
|
||||
fmt.Println("Error: cannot open config file")
|
||||
fmt.Println("Error: cannot open config file: config/" + env + ".json")
|
||||
os.Exit(-1)
|
||||
}
|
||||
decoder := json.NewDecoder(file)
|
||||
|
@ -84,8 +85,14 @@ func initTemplates() {
|
|||
|
||||
func main() {
|
||||
fmt.Println("transmet ", VERSION)
|
||||
|
||||
envFlag := flag.String("env", "local", "load config/{env}.json")
|
||||
flag.Parse()
|
||||
|
||||
|
||||
fmt.Println("Loading...")
|
||||
loadConfig()
|
||||
|
||||
loadConfig(*envFlag)
|
||||
dbConnect()
|
||||
initTemplates()
|
||||
init_route_handlers()
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# transmet: link storage server
|
||||
#
|
||||
# upstart init script
|
||||
|
||||
description "transmet link storage"
|
||||
author "Dan Ballard"
|
||||
|
||||
start on (net-device-up
|
||||
and local-filesystems
|
||||
and runlevel [2345])
|
||||
stop on (runlevel [016])
|
||||
|
||||
chdir /opt/transmet
|
||||
|
||||
respawn
|
||||
|
||||
exec transmet --env prod
|
Loading…
Reference in New Issue