Skip to content

Commit

Permalink
OK
Browse files Browse the repository at this point in the history
  • Loading branch information
upliveapp committed Jun 22, 2020
1 parent e527a3d commit 4eb6efd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
dkv
22 changes: 21 additions & 1 deletion component/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package config

import (
"flag"
"fmt"
"github.com/gin-gonic/gin"
"github.com/spf13/viper"
"log"
"net/http"
"os"
"os/exec"
"strings"
)

Expand All @@ -14,8 +17,25 @@ var (
)

func init() {
d := flag.Bool("d", false, "run app as a daemon with -d=true")
c := flag.String("conf", "config.yaml", "configure file")
flag.Parse()
if flag.Parsed() == false {
flag.Parse()
}
if *d {
args := os.Args[1:]
i := 0
for ; i < len(args); i++ {
if args[i] == "-d=true" {
args[i] = "-d=false"
break
}
}
cmd := exec.Command(os.Args[0], args...)
cmd.Start()
fmt.Println("[PID]", cmd.Process.Pid)
os.Exit(0)
}
// 配置文件设置
C = viper.New()
for _, t := range []string{"yaml", "yml"} {
Expand Down
Binary file removed dkv
Binary file not shown.
22 changes: 0 additions & 22 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,11 @@ import (
"dkv/component/pprof"
"dkv/store"
_ "dkv/store/synchronous"
"flag"
"fmt"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"os"
"os/exec"
)

func init() {
d := flag.Bool("d", false, "run app as a daemon with -d=true")
flag.Parse()
if *d {
args := os.Args[1:]
i := 0
for ; i < len(args); i++ {
if args[i] == "-d=true" {
args[i] = "-d=false"
break
}
}
cmd := exec.Command(os.Args[0], args...)
cmd.Start()
fmt.Println("[PID]", cmd.Process.Pid)
os.Exit(0)
}
}

func main() {
// 启动存储引擎
defer store.S.Close()
Expand Down

0 comments on commit 4eb6efd

Please sign in to comment.