mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
fixed issue w/ buffer blocking on write to websocket
This commit is contained in:
parent
fa0213ab8d
commit
6375eaa552
7 changed files with 22 additions and 22 deletions
|
@ -245,7 +245,13 @@ app.controller("CommitController", function($scope, $http, $routeParams, stdout,
|
|||
$scope.commit = data;
|
||||
|
||||
if (data.status!='Started' && data.status!='Pending') {
|
||||
return;
|
||||
$http({method: 'GET', url: '/v1/repos/'+remote+'/'+owner+"/"+name+"/branches/"+branch+"/commits/"+commit+"/console"}).
|
||||
success(function(data, status, headers, config) {
|
||||
$scope.console = data;
|
||||
}).
|
||||
error(function(data, status, headers, config) {
|
||||
console.log(data);
|
||||
});
|
||||
}
|
||||
|
||||
stdout.subscribe(data.id, function(out){
|
||||
|
@ -256,13 +262,6 @@ app.controller("CommitController", function($scope, $http, $routeParams, stdout,
|
|||
console.log(data);
|
||||
});
|
||||
|
||||
// load the repo build stdout
|
||||
$http({method: 'GET', url: '/v1/repos/'+remote+'/'+owner+"/"+name+"/branches/"+branch+"/commits/"+commit+"/console"}).
|
||||
success(function(data, status, headers, config) {
|
||||
$scope.console = data;
|
||||
}).
|
||||
error(function(data, status, headers, config) {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
|
||||
});
|
|
@ -16,6 +16,9 @@ angular.module('app').service('stdout', ['$window', function($window) {
|
|||
callback(event.data);
|
||||
}
|
||||
};
|
||||
websocket.onclose = function(event) {
|
||||
console.log('websocket closed at '+path);
|
||||
};
|
||||
};
|
||||
|
||||
this.unsubscribe = function() {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
</dl>
|
||||
</div>
|
||||
|
||||
<dl>
|
||||
<dd><h1>3.5 ms</h1></dd>
|
||||
<dl ng-if="commit.duration != 0">
|
||||
<dd><h1>{{ commit.duration | toDuration}}</h1></dd>
|
||||
</dl>
|
||||
|
||||
<dl>
|
||||
|
@ -19,7 +19,7 @@
|
|||
</aside>
|
||||
|
||||
<div id="main" class="output">
|
||||
<div id="main" class="output" data-result="Failure">
|
||||
<div id="main" class="output" data-result="{{ commit.status }}">
|
||||
<nav>
|
||||
<a href="/"><span class="fa fa-th"></span></a>
|
||||
<span>{{ repo.owner }}</span>
|
||||
|
|
|
@ -87,10 +87,6 @@ func main() {
|
|||
// cancel all previously running builds
|
||||
go commits.CancelAll()
|
||||
|
||||
// setup the build queue
|
||||
//queueRunner := queue.NewBuildRunner(docker.New(), timeout)
|
||||
//queue := queue.Start(work ers, commits, queueRunner)
|
||||
|
||||
queue := make(chan *worker.Request)
|
||||
workers := make(chan chan *worker.Request)
|
||||
worker.NewDispatch(queue, workers).Start()
|
||||
|
|
|
@ -22,7 +22,9 @@ func (b *Buffer) Write(p []byte) (n int, err error) {
|
|||
}
|
||||
|
||||
func (b *Buffer) WriteString(s string) (n int, err error) {
|
||||
return b.Write([]byte(s))
|
||||
n, err = b.buf.WriteString(s)
|
||||
b.channel.Publish([]byte(s))
|
||||
return
|
||||
}
|
||||
|
||||
func (b *Buffer) Bytes() []byte {
|
||||
|
|
|
@ -29,8 +29,7 @@ func NewChannel(opts *Opts) *Channel {
|
|||
}
|
||||
|
||||
func (c *Channel) Publish(data interface{}) {
|
||||
c.broadcast <- data
|
||||
return
|
||||
go func() { c.broadcast <- data }()
|
||||
}
|
||||
|
||||
func (c *Channel) Subscribe() *Subscription {
|
||||
|
|
|
@ -81,7 +81,7 @@ func (w *worker) Stop() {
|
|||
func (w *worker) Execute(r *Request) {
|
||||
// mark the build as Started and update the database
|
||||
r.Commit.Status = model.StatusStarted
|
||||
r.Commit.Started = time.Now().Unix()
|
||||
r.Commit.Started = time.Now().UTC().Unix()
|
||||
w.commits.Update(r.Commit)
|
||||
|
||||
// notify all listeners that the build is started
|
||||
|
@ -129,7 +129,7 @@ func (w *worker) Execute(r *Request) {
|
|||
builder.Repo = repo
|
||||
builder.Stdout = buf
|
||||
builder.Key = []byte(r.Repo.PrivateKey)
|
||||
builder.Timeout = time.Duration(r.Repo.Timeout) * time.Minute
|
||||
builder.Timeout = time.Duration(r.Repo.Timeout) * time.Second
|
||||
builder.Privileged = r.Repo.Privileged
|
||||
|
||||
// run the build
|
||||
|
@ -140,6 +140,7 @@ func (w *worker) Execute(r *Request) {
|
|||
switch {
|
||||
case err != nil:
|
||||
r.Commit.Status = model.StatusError
|
||||
log.Printf("Error building %s, Err: %s", r.Commit.Sha, err)
|
||||
buf.WriteString(err.Error())
|
||||
case builder.BuildState == nil:
|
||||
r.Commit.Status = model.StatusFailure
|
||||
|
@ -151,7 +152,7 @@ func (w *worker) Execute(r *Request) {
|
|||
|
||||
// calcualte the build finished and duration details and
|
||||
// update the commit
|
||||
r.Commit.Finished = time.Now().Unix()
|
||||
r.Commit.Finished = time.Now().UTC().Unix()
|
||||
r.Commit.Duration = (r.Commit.Finished - r.Commit.Started)
|
||||
w.commits.Update(r.Commit)
|
||||
w.commits.UpdateOutput(r.Commit, buf.Bytes())
|
||||
|
|
Loading…
Reference in a new issue