Skip to content

Commit

Permalink
add run.log, improve build script
Browse files Browse the repository at this point in the history
  • Loading branch information
iwind committed May 16, 2019
1 parent 2dfe5c4 commit 1d1309a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/main/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ export GOARCH=386

build

# linux arm64
export GOPATH=`pwd`/../../
export GOOS=linux
export GOARCH=arm64

build

# linux arm32
export GOPATH=`pwd`/../../
export GOOS=linux
export GOARCH=arm

build

# windows 64
export GOPATH=`pwd`/../../
export GOOS=windows
Expand Down
2 changes: 1 addition & 1 deletion src/main/configs/server.sample.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 'configs/server.conf' sample

# environment code
env: dev
env: prod

# http
http:
Expand Down
1 change: 1 addition & 0 deletions src/main/logs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.log
1 change: 1 addition & 0 deletions src/main/logs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`run.log` - runtime log
1 change: 1 addition & 0 deletions src/main/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function build() {
mkdir ${TARGET}/web/tmp
mkdir ${TARGET}/configs
mkdir ${TARGET}/data
mkdir ${TARGET}/logs

echo "[build static file]"

Expand Down
14 changes: 13 additions & 1 deletion src/source/github.com/TeaWeb/cluster-code/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/files"
"github.com/iwind/TeaGo/lists"
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/types"
"log"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -34,6 +36,16 @@ func (this *Shell) Start() {
// write current pid
files.NewFile(Tea.Root + Tea.DS + "bin" + Tea.DS + "pid").
WriteString(fmt.Sprintf("%d", os.Getpid()))

// log
if !Tea.IsTesting() {
fp, err := os.OpenFile(Tea.Root+"/logs/run.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
if err == nil {
log.SetOutput(fp)
} else {
logs.Println("[error]" + err.Error())
}
}
}

// reset root
Expand Down Expand Up @@ -84,7 +96,7 @@ func (this *Shell) execArgs() bool {
}

if len(args) > 0 {
fmt.Println("Unknown command option '" + strings.Join(args, " ") + "', run './bin/teaweb -h' to lookup the usage.")
fmt.Println("Unknown command option '" + strings.Join(args, " ") + "', run './bin/teaweb-cluster -h' to lookup the usage.")
return true
}
return false
Expand Down

0 comments on commit 1d1309a

Please sign in to comment.