37 lines
744 B
Go
37 lines
744 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"os/exec"
|
|
"time"
|
|
)
|
|
|
|
func pull_request() error {
|
|
contextCommand, cancelCommand := context.WithTimeout(context.Background(), 30*time.Second)
|
|
defer cancelCommand()
|
|
pull_command := exec.CommandContext(contextCommand, "./git_pull.sh")
|
|
|
|
output, err := pull_command.CombinedOutput()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if len(output) > 0 {
|
|
if string(output) == "Already up to date." || string(output) == "Coffee recipe updated." {
|
|
//logger.GetInstance().Info("Git pull successful", zap.String("output", string(output)))
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func RunGitRecipeWorker() {
|
|
//pull every 10 minutes
|
|
for {
|
|
err := pull_request()
|
|
if err != nil {
|
|
//fmt.Println(err)
|
|
}
|
|
time.Sleep(10 * time.Minute)
|
|
}
|
|
}
|