支持通过绝对路径运行gocron #45

develop
ouqiang 2018-04-17 21:10:21 +08:00
parent 83f8b67b20
commit 64128f37e0
3 changed files with 5 additions and 5 deletions

View File

@ -1,4 +1,4 @@
// main gocron // Command gocron
package main package main

View File

@ -1,5 +1,4 @@
// main gocron-node // Command gocron-node
package main package main
import ( import (

View File

@ -2,6 +2,7 @@ package app
import ( import (
"os" "os"
"path/filepath"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
@ -27,11 +28,11 @@ var (
func InitEnv(versionString string) { func InitEnv(versionString string) {
logger.InitLogger() logger.InitLogger()
wd, err := os.Getwd() var err error
AppDir, err = filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil { if err != nil {
logger.Fatal(err) logger.Fatal(err)
} }
AppDir = wd
ConfDir = AppDir + "/conf" ConfDir = AppDir + "/conf"
LogDir = AppDir + "/log" LogDir = AppDir + "/log"
DataDir = AppDir + "/data" DataDir = AppDir + "/data"