Skip to content

Commit e15eb85

Browse files
committed
Finished first logging part. Display of logs in UI still missing
1 parent 88058a3 commit e15eb85

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

plugin/plugin.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,21 @@ type Plugin struct {
4848
//
4949
// It expects the start command to start the plugin and the log path (including file)
5050
// where the output should be logged to.
51-
func NewPlugin(command *exec.Cmd, logPath string) (p *Plugin, err error) {
51+
func NewPlugin(command *exec.Cmd, logPath *string) (p *Plugin, err error) {
5252
// Allocate
5353
p = &Plugin{}
5454

5555
// Create log file and open it.
5656
// We will close this file in the close method.
57-
p.logFile, err = os.OpenFile(
58-
logPath,
59-
os.O_CREATE|os.O_WRONLY,
60-
0666,
61-
)
62-
if err != nil {
63-
return nil, err
57+
if logPath != nil {
58+
p.logFile, err = os.OpenFile(
59+
*logPath,
60+
os.O_CREATE|os.O_WRONLY,
61+
0666,
62+
)
63+
if err != nil {
64+
return nil, err
65+
}
6466
}
6567

6668
// Create new writer

scheduler/scheduler.go

+5-9
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func executeJob(job *gaia.Job, p *gaia.Pipeline, logPath string, wg *sync.WaitGr
226226
}
227227

228228
// Create new plugin instance
229-
pC, err := plugin.NewPlugin(c, logPath)
229+
pC, err := plugin.NewPlugin(c, &logPath)
230230
if err != nil {
231231
gaia.Cfg.Logger.Error("cannot initiate plugin before job execution", "error", err.Error())
232232
return
@@ -282,7 +282,7 @@ func (s *Scheduler) scheduleJobsByPriority(r *gaia.PipelineRun, p *gaia.Pipeline
282282

283283
// Execute this job in a separate goroutine
284284
path := filepath.Join(gaia.Cfg.WorkspacePath, strconv.Itoa(r.PipelineID), strconv.Itoa(r.ID), gaia.LogsFolderName)
285-
path = filepath.Join(path, strconv.Itoa(job.ID))
285+
path = filepath.Join(path, strconv.FormatUint(uint64(job.ID), 10))
286286
go executeJob(&r.Jobs[id], p, path, &wg, triggerSave)
287287
}
288288
}
@@ -334,17 +334,13 @@ func (s *Scheduler) getPipelineJobs(p *gaia.Pipeline) ([]gaia.Job, error) {
334334
return nil, errCreateCMDForPipeline
335335
}
336336

337-
// Create log folder (if not exist)
338-
path := filepath.Join(gaia.Cfg.WorkspacePath, strconv.Itoa(r.PipelineID), strconv.Itoa(r.ID), gaia.LogsFolderName)
339-
err := os.MkdirAll(path, 0700)
337+
// Create new plugin instance
338+
pC, err := plugin.NewPlugin(c, nil)
340339
if err != nil {
341-
gaia.Cfg.Logger.Error("cannot create folder before get pipeline jobs", "error", err.Error(), "path", path)
340+
gaia.Cfg.Logger.Error("cannot initiate plugin", "error", err.Error())
342341
return nil, err
343342
}
344343

345-
// Create new plugin instance
346-
pC, err := plugin.NewPlugin(c)
347-
348344
// Connect to plugin(pipeline)
349345
if err := pC.Connect(); err != nil {
350346
gaia.Cfg.Logger.Debug("cannot connect to pipeline", "error", err.Error(), "pipeline", p)

0 commit comments

Comments
 (0)