ソースを参照

Configuration to log files when startup

master
patrick 5年前
コミット
b641a0867b
3個のファイルの変更12行の追加9行の削除
  1. +0
    -1
      config.go
  2. +11
    -7
      main.go
  3. +1
    -1
      rpnIn.go

+ 0
- 1
config.go ファイルの表示

type AppConfig struct { type AppConfig struct {
Rpn struct { Rpn struct {
Url string `json:Url` Url string `json:Url`
UrlTest string `json:UrlTest`
MD5P2P string `json:MD5P2P` MD5P2P string `json:MD5P2P`
MD5FAT string `json:MD5FAT` MD5FAT string `json:MD5FAT`
MIDP2P string `json:MIDP2P` MIDP2P string `json:MIDP2P`

+ 11
- 7
main.go ファイルの表示

) )


func main() { func main() {
readConfig()
//readConfigForTest()
db.h = nil //make sure it's in proper state. db.h = nil //make sure it's in proper state.


filename := "rpn.superforex." + time.Now().Format("20060102150406") + ".log"
//setup log file
filename := "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) f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil { if err != nil {
log.Fatalf("error opening file: %v", err)
log.Fatalf("Error opening file: %v", err)
} }
defer f.Close() defer f.Close()
log.SetOutput(f) log.SetOutput(f)
log.Println("Server started on: http://localhost:8080")

//Read Config
readConfig()
//readConfigForTest()


//setup http handler //setup http handler
http.HandleFunc("/rpnNameAndCard", rpnNameAndCard) //ask name and card no http.HandleFunc("/rpnNameAndCard", rpnNameAndCard) //ask name and card no
http.HandleFunc("/alipay", leanworkInFAT) // leanwork in http.HandleFunc("/alipay", leanworkInFAT) // leanwork in
fs := wrapHandler(http.FileServer(http.Dir("./PG"))) //leanwork P2P embeded in fs := wrapHandler(http.FileServer(http.Dir("./PG"))) //leanwork P2P embeded in
http.HandleFunc("/", fs) http.HandleFunc("/", fs)
http.ListenAndServe(":8080", nil)


//start log file
//start listening
log.Println("Server started on: http://localhost:8080")
http.ListenAndServe(Config.Server.Host+":"+Config.Server.Port, nil)


//program never reach here.
} }


func errPage(w http.ResponseWriter, code int, msg string) { func errPage(w http.ResponseWriter, code int, msg string) {

+ 1
- 1
rpnIn.go ファイルの表示

s += "|pay_result=" + m.Pay_result s += "|pay_result=" + m.Pay_result
s += "|key=" + m.md5key() s += "|key=" + m.md5key()
sig = md5str(s) sig = md5str(s)
log.Println("signature of rpnIn = " + sig + " using key " + m.md5key())
//log.Println("signature of rpnIn = " + sig + " using key " + m.md5key())
return return
} }



読み込み中…
キャンセル
保存