mirror of
https://github.com/Luzifer/tex-api.git
synced 2024-11-09 08:40:02 +00:00
Add more verbose processing logs
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
a6fd458d40
commit
6048a58d28
1 changed files with 10 additions and 5 deletions
15
main.go
15
main.go
|
@ -270,27 +270,31 @@ func downloadAssets(res http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func jobProcessor(uid uuid.UUID) {
|
||||
logger := log.WithField("uuid", uid)
|
||||
logger.Info("Started processing")
|
||||
|
||||
processingDir := path.Dir(pathFromUUID(uid, filenameStatus))
|
||||
status, err := loadStatusByUUID(uid)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Unable to load status file in processing job")
|
||||
logger.WithError(err).Error("Unable to load status file in processing job")
|
||||
return
|
||||
}
|
||||
|
||||
cmd := exec.Command("/bin/bash", cfg.Script) // #nosec G204
|
||||
cmd.Dir = processingDir
|
||||
cmd.Stderr = log.StandardLogger().WriterLevel(log.ErrorLevel)
|
||||
cmd.Stderr = logger.WriterLevel(log.InfoLevel) // Bash uses stderr for `-x` parameter
|
||||
|
||||
status.UpdateStatus(statusStarted)
|
||||
if err := status.Save(); err != nil {
|
||||
log.WithError(err).Error("Unable to save status file")
|
||||
logger.WithError(err).Error("Unable to save status file")
|
||||
return
|
||||
}
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
logger.WithError(err).Error("Processing failed")
|
||||
status.UpdateStatus(statusError)
|
||||
if err := status.Save(); err != nil {
|
||||
log.WithError(err).Error("Unable to save status file")
|
||||
logger.WithError(err).Error("Unable to save status file")
|
||||
return
|
||||
}
|
||||
return
|
||||
|
@ -298,7 +302,8 @@ func jobProcessor(uid uuid.UUID) {
|
|||
|
||||
status.UpdateStatus(statusFinished)
|
||||
if err := status.Save(); err != nil {
|
||||
log.WithError(err).Error("Unable to save status file")
|
||||
logger.WithError(err).Error("Unable to save status file")
|
||||
return
|
||||
}
|
||||
logger.Info("Finished processing")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue