save
parent
905e1779a5
commit
7e89c07951
2
Makefile
2
Makefile
|
@ -5,4 +5,4 @@ run:
|
|||
APP_LOG_PRETTY=true \
|
||||
APP_DB_TYPE=sqlite \
|
||||
APP_DATA=work \
|
||||
go run main.go
|
||||
go run cmd/test/main.go
|
|
@ -1,3 +1,9 @@
|
|||
# Kumoly App
|
||||
|
||||
combine all needed module into one lib
|
||||
combine all needed module into one lib
|
||||
|
||||
## Run
|
||||
|
||||
```
|
||||
|
||||
```
|
|
@ -3,6 +3,8 @@ package history
|
|||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"kumoly.io/kumoly/app/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -26,19 +28,27 @@ type History struct {
|
|||
|
||||
var Tunnel chan *History
|
||||
var quit chan struct{}
|
||||
var started chan struct{}
|
||||
|
||||
func init() {
|
||||
Tunnel = make(chan *History)
|
||||
quit = make(chan struct{}, 1)
|
||||
started = make(chan struct{}, 1)
|
||||
}
|
||||
|
||||
func Start(r Receiver) {
|
||||
select {
|
||||
case started <- struct{}{}:
|
||||
default:
|
||||
panic(errors.New(500, "history has already started!"))
|
||||
}
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case h := <-Tunnel:
|
||||
r(h)
|
||||
case <-quit:
|
||||
<-started
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
export APP_SERVER_HOST=127.0.0.1
|
||||
export APP_SERVER_PORT=8000
|
||||
export APP_LOG_LEVEL=-1
|
||||
export APP_PROD=false
|
||||
export APP_LOG_PRETTY=true
|
||||
export APP_DB_TYPE=sqlite
|
||||
export APP_DATA=work
|
||||
go run cmd/test/main.go
|
|
@ -1,6 +1,7 @@
|
|||
package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -61,9 +62,24 @@ func setup() {
|
|||
if cc, ok := i.(string); ok {
|
||||
c = cc
|
||||
}
|
||||
// if len(c) > 0 {
|
||||
|
||||
// }
|
||||
if len(c) > 0 {
|
||||
// shorten caller to mod/file:line
|
||||
segs := strings.Split(c, ":")
|
||||
file := segs[len(segs)-2]
|
||||
short := file
|
||||
skip := false
|
||||
for i := len(file) - 1; i > 0; i-- {
|
||||
if file[i] == '/' {
|
||||
if !skip {
|
||||
skip = true
|
||||
continue
|
||||
}
|
||||
short = file[i+1:]
|
||||
break
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%v:%v", short, segs[len(segs)-1])
|
||||
}
|
||||
return c
|
||||
},
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue