hooked up websockets to stream output

This commit is contained in:
Brad Rydzewski 2014-02-07 04:09:46 -07:00
parent ac88f3a9e8
commit abdcd60dac
4 changed files with 10 additions and 9 deletions

View file

@ -354,7 +354,7 @@ func (b *Builder) run() error {
b.BuildState.Finished = time.Now().UTC().Unix()
// get the exit code if possible
b.BuildState.ExitCode = wait.StatusCode //b.container.State.ExitCode
b.BuildState.ExitCode = wait.StatusCode
return nil
}
@ -404,6 +404,7 @@ func (b *Builder) writeDockerfile(dir string) error {
dockerfile.WriteEnv("GOPATH", "/var/cache/drone")
dockerfile.WriteAdd("id_rsa", "/root/.ssh/id_rsa")
dockerfile.WriteRun("chmod 600 /root/.ssh/id_rsa")
dockerfile.WriteRun("echo 'StrictHostKeyChecking no' > /root/.ssh/config")
}
dockerfile.WriteAdd("proxy.sh", "/etc/drone.d/")

View file

@ -48,7 +48,7 @@ func CommitShow(w http.ResponseWriter, r *http.Request, u *User, repo *Repo) err
// generate a token to connect with the websocket
// handler and stream output, if the build is running.
data.Token = channel.Token(fmt.Sprintf(
data.Token = channel.CreateStream(fmt.Sprintf(
"%s/commit/%s/builds/%s", repo.Slug, commit.Hash, builds[0].Slug))
// render the repository template.

View file

@ -106,9 +106,9 @@ func (b *BuildTask) execute() error {
// make sure a channel exists for the repository,
// the commit, and the commit output (TODO)
reposlug := fmt.Sprintf("%s/%s/%s", b.Repo.Host, b.Repo.Owner, b.Repo.Slug)
commitslug := fmt.Sprintf("%s/%s/%s/commit/%s", b.Repo.Host, b.Repo.Owner, b.Repo.Slug, b.Commit.Hash)
consoleslug := fmt.Sprintf("%s/%s/%s/commit/%s/builds/%s", b.Repo.Host, b.Repo.Owner, b.Repo.Slug, b.Commit.Hash, b.Build.Slug)
reposlug := fmt.Sprintf("%s/%s/%s", b.Repo.Host, b.Repo.Owner, b.Repo.Name)
commitslug := fmt.Sprintf("%s/%s/%s/commit/%s", b.Repo.Host, b.Repo.Owner, b.Repo.Name, b.Commit.Hash)
consoleslug := fmt.Sprintf("%s/%s/%s/commit/%s/builds/%s", b.Repo.Host, b.Repo.Owner, b.Repo.Name, b.Commit.Hash, b.Build.Slug)
channel.Create(reposlug)
channel.Create(commitslug)
channel.CreateStream(consoleslug)
@ -223,7 +223,7 @@ func updateGitHubStatus(repo *Repo, commit *Commit) error {
}
client := github.New(user.GithubToken)
return client.Repos.CreateStatus(repo.Owner, repo.Slug, status, settings.URL().String(), message, commit.Hash)
return client.Repos.CreateStatus(repo.Owner, repo.Name, status, settings.URL().String(), message, commit.Hash)
}
func (t *BuildTask) sendEmail(c *notification.Context) error {
@ -250,7 +250,7 @@ func (t *BuildTask) sendFailureEmail(c *notification.Context) error {
// loop through and email recipients
for _, email := range t.Script.Notifications.Email.Recipients {
if err := mail.SendFailure(t.Repo.Slug, email, c); err != nil {
if err := mail.SendFailure(t.Repo.Name, email, c); err != nil {
return err
}
}
@ -263,7 +263,7 @@ func (t *BuildTask) sendSuccessEmail(c *notification.Context) error {
// loop through and email recipients
for _, email := range t.Script.Notifications.Email.Recipients {
if err := mail.SendSuccess(t.Repo.Slug, email, c); err != nil {
if err := mail.SendSuccess(t.Repo.Name, email, c); err != nil {
return err
}
}

View file

@ -64,7 +64,7 @@
outputWS.onclose = function (e) { window.location.reload(); };
outputWS.onmessage = function (e) {
outputBox.innerHTML += formatLine(e.data);
window.scrollTo(0, document.body.scrollHeight)
//window.scrollTo(0, document.body.scrollHeight)
};
var re = /\u001B\[([0-9]+;?)*[Km]/g;
var styles = new Array();