Skip to content

Commit

Permalink
1. 更新版本及文档
Browse files Browse the repository at this point in the history
2. 修复windows不兼容问题

Signed-off-by: 孙林耀 <[email protected]>
  • Loading branch information
MicroOps-cn committed Jun 2, 2022
1 parent 753c8bc commit 8e7c2e3
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 29 deletions.
7 changes: 4 additions & 3 deletions README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ HTTP response message, local file, TCP response message and UDP response message
#### Local Build

```shell
make
make common-build
```

#### Building with Docker

```shell
make && docker build -t data_exporter:0.2.0 .
make && docker build -t data_exporter:0.4.0 .
```

### Running this software
Expand Down Expand Up @@ -51,7 +51,8 @@ curl 127.0.0.1:9116/metrics
```shell
git clone https://github.com/MicroOps-cn/data_exporter
cd data_exporter/examples/
docker run -itd -p 9116:9116 -v `pwd`:/etc/data_exporter/ --name data_exporter microops/data_exporter:0.3.2 --config.path=/etc/data_exporter/data_exporter.yaml
sed -i 's#../examples/#/etc/data_exporter/#g' data_exporter.yaml
docker run -itd -p 9116:9116 -v `pwd`:/etc/data_exporter/ --name data_exporter microops/data_exporter:0.4.0 --config.path=/etc/data_exporter/data_exporter.yaml
docker logs data_exporter
```

Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ HTTP response message, local file, TCP response message and UDP response message
#### 通用

```shell
make
make common-build
```

#### 编译Docker镜像

```shell
make && docker build -t data_exporter:0.2.0 .
make && docker build -t data_exporter:0.4.0 .
```

### 运行
Expand All @@ -35,7 +35,7 @@ make && docker build -t data_exporter:0.2.0 .
#### 调试配置文件

```shell
./data_exporter --config.path="data_exporter.yaml" --log.level=debug
./data_exporter debug --config.path="data_exporter.yaml"
```

#### 启动examples
Expand All @@ -53,7 +53,8 @@ curl 127.0.0.1:9116/metrics
```shell
git clone https://github.com/MicroOps-cn/data_exporter
cd data_exporter/examples/
docker run -itd -p 9116:9116 -v `pwd`:/etc/data_exporter/ --name data_exporter microops/data_exporter:0.3.2 --config.path=/etc/data_exporter/data_exporter.yaml
sed -i 's#../examples/#/etc/data_exporter/#g' data_exporter.yaml
docker run -itd -p 9116:9116 -v `pwd`:/etc/data_exporter/ --name data_exporter microops/data_exporter:0.4.0 --config.path=/etc/data_exporter/data_exporter.yaml
docker logs data_exporter
```

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.2
0.4.0
21 changes: 0 additions & 21 deletions pkg/term/term.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,8 @@ package term
import (
"bytes"
"fmt"
"syscall"
"unsafe"
)

func terminalWidth() (int, error) {
type window struct {
Row uint16
Col uint16
Xpixel uint16
Ypixel uint16
}
w := new(window)
tio := syscall.TIOCGWINSZ
res, _, err := syscall.Syscall(syscall.SYS_IOCTL,
uintptr(syscall.Stdin),
uintptr(tio),
uintptr(unsafe.Pointer(w)),
)
if int(res) == -1 {
return 0, err
}
return int(w.Col), nil
}
func TitleStr(name string, sep rune) string {
var width int
var err error
Expand Down
28 changes: 28 additions & 0 deletions pkg/term/term_unixlike.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//go:build darwin || linux

package term

import (
"syscall"
"unsafe"
)

func terminalWidth() (int, error) {
type window struct {
Row uint16
Col uint16
Xpixel uint16
Ypixel uint16
}
w := new(window)
tio := syscall.TIOCGWINSZ
res, _, err := syscall.Syscall(syscall.SYS_IOCTL,
uintptr(syscall.Stdin),
uintptr(tio),
uintptr(unsafe.Pointer(w)),
)
if int(res) == -1 {
return 0, err
}
return int(w.Col), nil
}
5 changes: 5 additions & 0 deletions pkg/term/term_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package term

func terminalWidth() (int, error) {
return 50, nil
}

0 comments on commit 8e7c2e3

Please sign in to comment.