mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 12:30:41 +01:00
log fwding
This commit is contained in:
parent
ca321053ae
commit
8b5d6b9803
@ -76,7 +76,13 @@ app.run(['$rootScope', '$window', '$couchPotato', '$injector', '$state', '$http'
|
||||
}
|
||||
|
||||
$rootScope.ws.onmessage = function (e) {
|
||||
console.log('msg', e.data);
|
||||
try {
|
||||
var d = JSON.parse(e.data);
|
||||
console.log(d);
|
||||
setTimeout(function () {
|
||||
$rootScope.$broadcast('remote.' + d.type, d);
|
||||
}, 3000);
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,10 @@ define(function () {
|
||||
}]);
|
||||
|
||||
app.registerController('TaskCtrl', ['$scope', '$http', function ($scope, $http) {
|
||||
$scope.$on('remote.log', function (evt, data) {
|
||||
$scope.output_formatted.splice(0, 0, data);
|
||||
});
|
||||
|
||||
$http.get($scope.project.getURL() + '/tasks/' + $scope.task.id + '/output')
|
||||
.success(function (output) {
|
||||
var out = [];
|
||||
|
@ -2,6 +2,7 @@ package tasks
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"os/exec"
|
||||
|
||||
"github.com/ansible-semaphore/semaphore/database"
|
||||
@ -10,7 +11,18 @@ import (
|
||||
|
||||
func (t *task) log(msg string) {
|
||||
for _, user := range t.users {
|
||||
sockets.Message(user, []byte(msg))
|
||||
b, err := json.Marshal(&map[string]interface{}{
|
||||
"type": "log",
|
||||
"m": msg,
|
||||
"task_id": t.task.ID,
|
||||
"project_id": t.projectID,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
sockets.Message(user, b)
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
Loading…
Reference in New Issue
Block a user