1
0
Fork 0
mirror of https://github.com/Luzifer/tex-api.git synced 2024-11-08 16:20:04 +00:00

Add more verbose processing logs

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-09-17 12:17:52 +02:00
parent a6fd458d40
commit 6048a58d28
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

15
main.go
View file

@ -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")
}