{{ .Stdout }}- +
diff --git a/assets/swirl/css/swirl.css b/assets/swirl/css/swirl.css index 4e48cdf..0ced37f 100644 --- a/assets/swirl/css/swirl.css +++ b/assets/swirl/css/swirl.css @@ -245,6 +245,14 @@ dd { border-top-right-radius: 0 !important; } +.code { + font-family: monospace; +} + +textarea.code{ + padding: 0.75em; +} + .CodeMirror { font-size: 0.8em; border: 1px solid #ddd; diff --git a/biz/docker/service.go b/biz/docker/service.go index 6a785bf..1410c77 100644 --- a/biz/docker/service.go +++ b/biz/docker/service.go @@ -1,19 +1,15 @@ package docker import ( + "bytes" "context" "errors" + "io" "sort" + "strconv" "strings" "time" - "io" - - "bufio" - "bytes" - - "strconv" - "github.com/cuigh/swirl/misc" "github.com/cuigh/swirl/model" "github.com/docker/docker/api/types" @@ -21,6 +17,7 @@ import ( "github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/client" + "github.com/docker/docker/pkg/stdcopy" ) // ServiceList return service list. @@ -523,37 +520,30 @@ func ServiceRemove(name string) error { // ServiceLogs returns the logs generated by a service. func ServiceLogs(name string, line int, timestamps bool) (stdout, stderr *bytes.Buffer, err error) { - err = mgr.Do(func(ctx context.Context, cli *client.Client) (err error) { - var ( - rc io.ReadCloser - buf []byte - ) - opts := types.ContainerLogsOptions{ - ShowStdout: true, - ShowStderr: true, - Tail: strconv.Itoa(line), - Timestamps: timestamps, - //Since: (time.Hour * 24).String() - } - if rc, err = cli.ServiceLogs(ctx, name, opts); err == nil { - defer rc.Close() + var ( + ctx context.Context + cli *client.Client + rc io.ReadCloser + ) - stdout = &bytes.Buffer{} - stderr = &bytes.Buffer{} - scanner := bufio.NewScanner(rc) - for scanner.Scan() { - buf = scanner.Bytes() - if buf[0] == 1 { - stdout.Write(buf[8:]) - stdout.WriteByte('\n') - } else if buf[0] == 2 { - stdout.Write(buf[8:]) - stdout.WriteByte('\n') - } - } - err = scanner.Err() - } + ctx, cli, err = mgr.Client() + if err != nil { return - }) + } + + opts := types.ContainerLogsOptions{ + ShowStdout: true, + ShowStderr: true, + Tail: strconv.Itoa(line), + Timestamps: timestamps, + //Since: (time.Hour * 24).String() + } + if rc, err = cli.ServiceLogs(ctx, name, opts); err == nil { + defer rc.Close() + + stdout = &bytes.Buffer{} + stderr = &bytes.Buffer{} + _, err = stdcopy.StdCopy(stdout, stderr, rc) + } return } diff --git a/model/setting.go b/model/setting.go index a3bd094..26657be 100644 --- a/model/setting.go +++ b/model/setting.go @@ -20,6 +20,6 @@ type Setting struct { UpdatedAt time.Time `bson:"updated_at" json:"updated_at,omitempty"` } -func Test() { +func Test() { time.Now().Zone() } diff --git a/views/_layouts/default.jet b/views/_layouts/default.jet index 450cb28..70f7924 100644 --- a/views/_layouts/default.jet +++ b/views/_layouts/default.jet @@ -4,7 +4,7 @@ - + {{ block style() }}{{end}} diff --git a/views/_layouts/empty.jet b/views/_layouts/empty.jet index d6d8956..f932eaa 100644 --- a/views/_layouts/empty.jet +++ b/views/_layouts/empty.jet @@ -4,7 +4,7 @@ - +
diff --git a/views/service/logs.jet b/views/service/logs.jet index 5c69473..26cdd83 100644 --- a/views/service/logs.jet +++ b/views/service/logs.jet @@ -77,7 +77,7 @@ -