Commit 4f9160d9 authored by Kamil Trzciński's avatar Kamil Trzciński 🔴

Multi runner can run jobs on Heroku

parent b5cb86b3
export BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-go
github.com/ayufan/gitlab-ci-multi-runner
{
"ImportPath": "github.com/ayufan/gitlab-ci-multi-runner",
"GoVersion": "go1.4",
"Deps": [
{
"ImportPath": "code.google.com/p/go.crypto/ssh",
"Comment": "null-236",
"Rev": "69e2a90ed92d03812364aeb947b7068dc42e561e"
},
{
"ImportPath": "github.com/BurntSushi/toml",
"Comment": "v0.1.0-9-g3883ac1",
"Rev": "3883ac1ce943878302255f538fce319d23226223"
},
{
"ImportPath": "github.com/Sirupsen/logrus",
"Comment": "v0.6.1-12-g0ae5377",
"Rev": "0ae53775f7736dbe9bbccbedb3c408f13ce5282e"
},
{
"ImportPath": "github.com/codegangsta/cli",
"Comment": "1.2.0-42-gfbda1ce",
"Rev": "fbda1ce02d5dabcee952040e5f4025753b6c9ce0"
},
{
"ImportPath": "github.com/docker/docker/pkg/archive",
"Comment": "v1.4.1-685-gb1f2fde",
"Rev": "b1f2fdeee213c437a363db9eda235444ffdcc4a5"
},
{
"ImportPath": "github.com/docker/docker/pkg/fileutils",
"Comment": "v1.4.1-685-gb1f2fde",
"Rev": "b1f2fdeee213c437a363db9eda235444ffdcc4a5"
},
{
"ImportPath": "github.com/docker/docker/pkg/ioutils",
"Comment": "v1.4.1-685-gb1f2fde",
"Rev": "b1f2fdeee213c437a363db9eda235444ffdcc4a5"
},
{
"ImportPath": "github.com/docker/docker/pkg/pools",
"Comment": "v1.4.1-685-gb1f2fde",
"Rev": "b1f2fdeee213c437a363db9eda235444ffdcc4a5"
},
{
"ImportPath": "github.com/docker/docker/pkg/promise",
"Comment": "v1.4.1-685-gb1f2fde",
"Rev": "b1f2fdeee213c437a363db9eda235444ffdcc4a5"
},
{
"ImportPath": "github.com/docker/docker/pkg/system",
"Comment": "v1.4.1-685-gb1f2fde",
"Rev": "b1f2fdeee213c437a363db9eda235444ffdcc4a5"
},
{
"ImportPath": "github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar",
"Comment": "v1.4.1-685-gb1f2fde",
"Rev": "b1f2fdeee213c437a363db9eda235444ffdcc4a5"
},
{
"ImportPath": "github.com/fsouza/go-dockerclient",
"Rev": "5da2a37ecfb5bcb921a36dbc18e912c3235f139a"
}
]
}
This directory tree is generated automatically by godep.
Please do not edit.
See https://github.com/tools/godep for more information.
web: gitlab-ci-multi-runner run-single -addr=":$PORT" -builds-dir="/tmp"
......@@ -8,14 +8,67 @@ import (
log "github.com/Sirupsen/logrus"
"github.com/ayufan/gitlab-ci-multi-runner/common"
"net/http"
)
func serverHelloWorld(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Write([]byte("{}"))
}
func runServer(addr string) error {
if len(addr) == 0 {
return nil
}
http.HandleFunc("/", serverHelloWorld)
err := http.ListenAndServe(addr, nil)
if err != nil {
log.Fatal(err)
return err
}
return nil
}
func runHerokuUrl(addr string) error {
if len(addr) == 0 {
return nil
}
for {
resp, err := http.Get(addr)
if err == nil {
log.Infoln("HEROKU_URL acked!")
defer resp.Body.Close()
} else {
log.Infoln("HEROKU_URL error: ", err)
}
time.Sleep(5 * time.Minute)
}
}
func runSingle(c *cli.Context) {
runner := common.RunnerConfig{
URL: c.String("URL"),
Token: c.String("token"),
URL: c.String("url"),
Token: c.String("token"),
Executor: c.String("executor"),
BuildsDir: c.String("builds-dir"),
}
if len(runner.URL) == 0 {
log.Fatalln("Missing URL")
}
if len(runner.Token) == 0 {
log.Fatalln("Missing Token")
}
if len(runner.Executor) == 0 {
log.Fatalln("Missing Executor")
}
go runServer(c.String("addr"))
go runHerokuUrl(c.String("heroku-url"))
log.Println("Starting runner for", runner.URL, "with token", runner.ShortDescription(), "...")
for {
......@@ -57,6 +110,30 @@ var (
Usage: "Runner URL",
EnvVar: "CI_SERVER_URL",
},
cli.StringFlag{
Name: "executor",
Value: "shell",
Usage: "Executor",
EnvVar: "RUNNER_EXECUTOR",
},
cli.StringFlag{
Name: "addr",
Value: "",
Usage: "Hello World Server",
EnvVar: "",
},
cli.StringFlag{
Name: "heroku-url",
Value: "",
Usage: "Current application address",
EnvVar: "HEROKU_URL",
},
cli.StringFlag{
Name: "builds-dir",
Value: "",
Usage: "Custom builds directory",
EnvVar: "RUNNER_BUILDS_DIR",
},
},
}
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment