| @@ -35,12 +35,14 @@ var Config AppConfig | |||
| func readConfig() error { | |||
| log.Println("Read configration for production ") | |||
| return readConfigFile("config.json") | |||
| workingdir := getWorkingDir() | |||
| return readConfigFile(workingdir + "/config.json") | |||
| } | |||
| func readConfigForTest() error { | |||
| log.Println("Read configration for Test ") | |||
| return readConfigFile("config.test.json") | |||
| workingdir := getWorkingDir() | |||
| return readConfigFile(workingdir + "/config.test.json") | |||
| } | |||
| func readConfigFile(file string) error { | |||
| @@ -1,2 +1,12 @@ | |||
| #!/bin/bash | |||
| echo compile program | |||
| echo "compile program to rpn " | |||
| go build -o rpn | |||
| scp rpn rpn@hk-01.biukop.com:~/go/ | |||
| scp config.json rpn@hk-01.biukop.com:~/go/ | |||
| rsync -a --exclude _pgbackup PG rpn@hk-01.biukop.com:~/go/ | |||
| rsync -a form rpn@hk-01.biukop.com:~/go/ | |||
| echo 'stop remote rpn and start new one' | |||
| ssh root@hk-01.biukop.com "/usr/sbin/service rpn stop; /usr/sbin/service rpn start" | |||
| @@ -4,6 +4,7 @@ import ( | |||
| "log" | |||
| "net/http" | |||
| "os" | |||
| "path/filepath" | |||
| "text/template" | |||
| "time" | |||
| ) | |||
| @@ -11,8 +12,10 @@ import ( | |||
| func main() { | |||
| db.h = nil //make sure it's in proper state. | |||
| workingdir := getWorkingDir() | |||
| //setup log file | |||
| filename := "logs/rpn.superforex." + time.Now().Format("2006-01-02-15-04-06") + ".log" | |||
| filename := workingdir + "/logs/rpn.superforex." + time.Now().Format("2006-01-02-15-04-06") + ".log" | |||
| f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) | |||
| if err != nil { | |||
| log.Fatalf("Error opening file: %v", err) | |||
| @@ -39,6 +42,14 @@ func main() { | |||
| //program never reach here. | |||
| } | |||
| func getWorkingDir() string { | |||
| dir, err := filepath.Abs(filepath.Dir(os.Args[0])) | |||
| if err != nil { | |||
| log.Fatal(err) | |||
| } | |||
| return dir | |||
| } | |||
| func errPage(w http.ResponseWriter, code int, msg string) { | |||
| var data struct { | |||
| ErrorMessage string | |||