Skip to content

Commit

Permalink
Merge pull request #51 from tuna/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
bigeagle authored Nov 19, 2016
2 parents 6225e86 + 03d22b7 commit 6dd06c9
Show file tree
Hide file tree
Showing 30 changed files with 46 additions and 841 deletions.
11 changes: 4 additions & 7 deletions .testandcover.bash
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#!/bin/bash


function die() {
echo $*
exit 1
}

export GOPATH=`pwd`:$GOPATH

make
make travis

# Initialize profile.cov
echo "mode: count" > profile.cov
Expand All @@ -19,10 +17,9 @@ ERROR=""
# Test each package and append coverage profile info to profile.cov
for pkg in `cat .testpackages.txt`
do
#$HOME/gopath/bin/
go test -v -covermode=count -coverprofile=profile_tmp.cov $pkg || ERROR="Error testing $pkg"

[ -f profile_tmp.cov ] && {
go test -v -covermode=count -coverprofile=profile_tmp.cov $pkg || ERROR="Error testing $pkg"

[ -f profile_tmp.cov ] && {
tail -n +2 profile_tmp.cov >> profile.cov || die "Unable to append coverage for $pkg"
}
done
Expand Down
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,17 @@ script:

after_success:
- goveralls -coverprofile=profile.cov -service=travis-ci

before_deploy: "echo 'ready to deploy?'"

deploy:
provider: releases
file:
- "build/tunasync-linux-bin.tar.gz"
api_key:
secure: "F9kaVaR1mxEh2+EL9Nm8GZmbVY98pXCJA0LGDNrq1C2vU61AUNOeX6yI1mMklHNZPLBqoFDvGN1M5HnJ+xWCFH+KnJgLD2GVIAcAxFNpcNWQe8XKE5heklNsIQNQfuh/rJKM6YzeDB9G5RN4Y76iL4WIAXhNnMm48W6jLnWhf70="
skip_cleanup: true
overwrite: true
on:
tags: true
all_branches: true
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ LDFLAGS="-X main.buildstamp=`date -u '+%s'` -X main.githash=`git rev-parse HEAD`

all: get tunasync tunasynctl

travis: get tunasync tunasynctl travis-package

get:
go get ./cmd/tunasync
go get ./cmd/tunasynctl
Expand All @@ -14,3 +16,6 @@ tunasync: build

tunasynctl: build
go build -o build/tunasynctl -ldflags ${LDFLAGS} github.com/tuna/tunasync/cmd/tunasynctl

travis-package: tunasync tunasynctl
tar zcf build/tunasync-linux-bin.tar.gz -C build tunasync tunasynctl
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ tunasync

- [中文文档](https://github.com/tuna/tunasync/blob/master/docs/zh_CN/get_started.md)

## Download

Pre-built binary for Linux x86_64 is available at [Github releases](https://github.com/tuna/tunasync/releases/latest).

## Design

Expand Down
16 changes: 8 additions & 8 deletions cmd/tunasync/tunasync.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"syscall"
"time"

"github.com/codegangsta/cli"
"github.com/gin-gonic/gin"
"github.com/pkg/profile"
"gopkg.in/op/go-logging.v1"
"gopkg.in/urfave/cli.v1"

tunasync "github.com/tuna/tunasync/internal"
"github.com/tuna/tunasync/manager"
Expand All @@ -25,7 +25,7 @@ var (

var logger = logging.MustGetLogger("tunasync")

func startManager(c *cli.Context) {
func startManager(c *cli.Context) error {
tunasync.InitLogger(c.Bool("verbose"), c.Bool("debug"), c.Bool("with-systemd"))

cfg, err := manager.LoadConfig(c.String("config"), c)
Expand All @@ -45,9 +45,10 @@ func startManager(c *cli.Context) {

logger.Info("Run tunasync manager server.")
m.Run()
return nil
}

func startWorker(c *cli.Context) {
func startWorker(c *cli.Context) error {
tunasync.InitLogger(c.Bool("verbose"), c.Bool("debug"), c.Bool("with-systemd"))
if !c.Bool("debug") {
gin.SetMode(gin.ReleaseMode)
Expand Down Expand Up @@ -103,6 +104,7 @@ func startWorker(c *cli.Context) {

logger.Info("Run tunasync worker.")
w.Run()
return nil
}

func main() {
Expand All @@ -129,6 +131,8 @@ func main() {
}

app := cli.NewApp()
app.Name = "tunasync"
app.Usage = "tunasync mirror job management tool"
app.EnableBashCompletion = true
app.Version = "0.1"
app.Commands = []cli.Command{
Expand Down Expand Up @@ -158,10 +162,6 @@ func main() {
Name: "key",
Usage: "Use SSL key from `FILE`",
},
cli.StringFlag{
Name: "status-file",
Usage: "Write status file to `FILE`",
},
cli.StringFlag{
Name: "db-file",
Usage: "Use `FILE` as the database file",
Expand Down Expand Up @@ -205,7 +205,7 @@ func main() {
},
cli.BoolFlag{
Name: "debug",
Usage: "Run manager in debug mode",
Usage: "Run worker in debug mode",
},
cli.BoolFlag{
Name: "with-systemd",
Expand Down
4 changes: 3 additions & 1 deletion cmd/tunasynctl/tunasynctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"time"

"github.com/BurntSushi/toml"
"github.com/codegangsta/cli"
"gopkg.in/op/go-logging.v1"
"gopkg.in/urfave/cli.v1"

tunasync "github.com/tuna/tunasync/internal"
)
Expand Down Expand Up @@ -323,6 +323,8 @@ func main() {
app := cli.NewApp()
app.EnableBashCompletion = true
app.Version = "0.1"
app.Name = "tunasynctl"
app.Usage = "control client for tunasync manager"

commonFlags := []cli.Flag{
cli.StringFlag{
Expand Down
23 changes: 6 additions & 17 deletions docs/zh_CN/get_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ date: 2016-10-31 00:50:00

### 二进制包

TODO
[Github Releases](https://github.com/tuna/tunasync/releases/latest) 下载 `tunasync-linux-bin.tar.gz` 即可。

### 自行编译

Expand Down Expand Up @@ -57,8 +57,11 @@ listen_port = 6000
ssl_cert = ""
ssl_key = ""
[include]
include_mirrors = "mirrors/*.conf"
[[mirrors]]
name = "elvish"
provider = "rsync"
upstream = "rsync://rsync.elvish.io/elvish/"
use_ipv6 = false
```

`~/tunasync_demo/manager.conf`:
Expand All @@ -78,20 +81,6 @@ db_file = "/tmp/tunasync/manager.db"
ca_cert = ""
```

### 镜像脚本

```
$ mkdir ~/tunasync_demo/mirrors
$ cat > ~/tunasync_demo/mirrors/elvish.conf < EOF
[[mirrors]]
name = "elvish"
provider = "rsync"
upstream = "rsync://rsync.elvish.io/elvish/"
use_ipv6 = false
EOF
```

### 运行

```
Expand Down
2 changes: 1 addition & 1 deletion manager/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package manager

import (
"github.com/BurntSushi/toml"
"github.com/codegangsta/cli"
"gopkg.in/urfave/cli.v1"
)

// A Config is the top-level toml-serializaible config struct
Expand Down
2 changes: 1 addition & 1 deletion manager/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"testing"

"github.com/BurntSushi/toml"
"github.com/codegangsta/cli"
. "github.com/smartystreets/goconvey/convey"
"gopkg.in/urfave/cli.v1"
)

func TestConfig(t *testing.T) {
Expand Down
96 changes: 0 additions & 96 deletions scripts/anaconda.sh

This file was deleted.

21 changes: 0 additions & 21 deletions scripts/aosp.sh

This file was deleted.

Loading

0 comments on commit 6dd06c9

Please sign in to comment.