Skip to content
This repository was archived by the owner on Feb 27, 2022. It is now read-only.

Commit f08d84a

Browse files
author
Reto Lehmann
committed
Build via travis.
1 parent a71589a commit f08d84a

File tree

4 files changed

+50
-15
lines changed

4 files changed

+50
-15
lines changed

.travis.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
language: go
2+
go:
3+
- 1.8.x
4+
5+
before_install:
6+
- go get github.com/mitchellh/gox
7+
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install stable
8+
9+
install:
10+
- go get github.com/gin-gonic/gin
11+
- go get github.com/sirupsen/logrus
12+
- go get github.com/gorilla/websocket
13+
14+
script:
15+
- mkdir -p ./dist/static/dist
16+
17+
# Build golang
18+
- gox -osarch="linux/amd64" -output "./dist/{{.Dir}}" github.com/retocode/openshift-cross-cluster-loadbalancer
19+
20+
# Build the UI
21+
- cd ./ui
22+
- npm install
23+
- npm run build
24+
- cp ./dist/build.js ../../dist/static/dist
25+
- cp index.html ../../dist/static
26+
- pwd # /home/travis/gopath/src/github.com/retocode/openshift-cross-cluster-loadbalancer/ui
27+
- cd ..
28+
- pwd # /home/travis/gopath/src/github.com/retocode/openshift-cross-cluster-loadbalancer
29+
- ls
30+
- ls dist/
31+
32+
# Pack the smart load balancer
33+
- tar -zcvf smart-load-balancer.tar.gz dist/openshift-cross-cluster-loadbalancer dist/static/index.html dist/static/dist
34+
35+
deploy:
36+
provider: releases
37+
api_key:
38+
secure: aUPqkwrlK4xps/e9NipGHQ/9UxuHNS2ygXiDV6f3+H4als67/yzEJ54CIKmY2B7WseA86HHtKh56Eh4W56a+uM/DJAxsPfS8c8igpXy8YVe2g4LwZ3u1HGrsfBcf5+X0X+o8K71I2OFiy7gkZGXKAf45yQLATn+O9dwJrxy119JkCqGPrg6LJ8AEi7btTAARlyRLgYoudBmuMjUifO+YDE4MMKBTPx1g84wCL5z+Eu6JFzUEsiE/aNvfHr7hTjCBdhZW9UseOcYAR8XJ5zksRj1rHP6rbQ2vkm7fmlSAnLypdD7my4jnSgJ4wzj9Qg4OrlNVW735Y5FuT9RmOWKzrk1X7fNavdNjyhmZZO86bb02iEzS3igCKAqX7+0KJdj7ZUTYLCGoFoW6HU6sotQtWPOVPcXjt+Ozpo4F4iKiaK5TI3aS8TRXZAdwHE27ZBbly6cwtUSQ5xknB9xVlLhuwghqvesELT6ALJfwe6h0Ou4g6vn4lJLwu4PxmL6vTUZ8CGLGVu+8rfBHcZp8SROzzp/F9SSgjkdUY0p29eHuHi1TfA5dSJooZ4Lul/FhkDe4tp7waqP3b7VA33xLHkY9alE8An6xh/x0gCA91vwgm0Ib39l86aNmBdAJlusxkTWoB/B1rpu45MXsw567zX/oX1sArr9e3LNxzUujr+v4yRY=
39+
file:
40+
- smart-load-balancer.tar.gz
41+
skip_cleanup: true
42+
on:
43+
tags: true

balancer/api/apiserver.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import (
66
"sync"
77

88
"github.com/ReToCode/openshift-cross-cluster-loadbalancer/balancer"
9+
"github.com/ReToCode/openshift-cross-cluster-loadbalancer/balancer/core"
910
"github.com/gin-gonic/gin"
1011
"github.com/gorilla/websocket"
1112
"github.com/sirupsen/logrus"
12-
"github.com/ReToCode/openshift-cross-cluster-loadbalancer/balancer/core"
1313
)
1414

1515
func init() {
@@ -33,13 +33,17 @@ func RunAPI(bind string, b *balancer.Balancer) {
3333
router := gin.New()
3434
router.Use(gin.Recovery())
3535

36+
router.GET("/", func(c *gin.Context) {
37+
c.Redirect(http.StatusTemporaryRedirect, "/s/")
38+
})
3639
router.GET("/ws", func(c *gin.Context) {
3740
onUISocket(c.Writer, c.Request, b)
3841
})
3942
router.POST("/ui/resetstats", func(c *gin.Context) {
4043
b.Scheduler.ResetStats <- true
4144
c.Status(http.StatusOK)
4245
})
46+
router.StaticFS("/s/", http.Dir("static"))
4347
router.POST("/api/cluster/:clusterkey", func(c *gin.Context) {
4448
clusterKey := c.Param("clusterkey")
4549

main.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,15 @@ import (
44
"os"
55

66
"os/signal"
7-
"runtime"
87
"syscall"
98

109
"github.com/ReToCode/openshift-cross-cluster-loadbalancer/balancer"
1110
"github.com/ReToCode/openshift-cross-cluster-loadbalancer/balancer/api"
1211
"github.com/sirupsen/logrus"
13-
14-
"net/http"
15-
_ "net/http/pprof"
1612
)
1713

1814
func init() {
1915
logrus.SetOutput(os.Stdout)
20-
//logrus.SetLevel(logrus.DebugLevel)
2116
logrus.SetLevel(logrus.InfoLevel)
2217
}
2318

@@ -35,15 +30,8 @@ func main() {
3530
logrus.Fatalf("Signal (%v) Detected, Shutting Down", sig)
3631
}()
3732

38-
// Profiling
39-
runtime.SetMutexProfileFraction(5)
40-
41-
go func() {
42-
logrus.Println(http.ListenAndServe("localhost:6060", nil))
43-
}()
44-
4533
// Dummy config to develop
46-
b := balancer.NewBalancer("localhost:8080", "localhost:8543")
34+
b := balancer.NewBalancer(":8080", ":8443")
4735
b.Start()
4836

4937
// Run web server

ui/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
</head>
88
<body>
99
<div id="app"></div>
10-
<script src="/dist/build.js"></script>
10+
<script src="dist/build.js"></script>
1111
</body>
1212
</html>

0 commit comments

Comments
 (0)