Skip to content

Commit

Permalink
final for daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
NorseGaud committed Apr 8, 2024
1 parent d4d43c2 commit 7e26588
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 31 deletions.
1 change: 0 additions & 1 deletion internal/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func RemoveUniqueKeyFromDB(ctx context.Context) {
}
logging := logging.GetLoggerFromContext(ctx)
// we don't use ctx for the database deletion so we avoid getting the cancelled context state, which fails when Del runs
fmt.Println("UID ", database.UniqueRunKey)
deletion, err := database.Client.Del(context.Background(), database.UniqueRunKey).Result()
if err != nil {
panic(err)
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var (

func termHandler(ctx context.Context, logger *slog.Logger) daemon.SignalHandlerFunc {
return func(sig os.Signal) error {
logger.InfoContext(ctx, "terminating anklet, please do not interrupt...")
logger.WarnContext(ctx, "terminating anklet, please do not interrupt...")
stop <- struct{}{}
if sig == syscall.SIGQUIT {
<-done
Expand Down Expand Up @@ -150,10 +150,10 @@ LOOP:
sig := <-sigChan
switch sig {
case syscall.SIGTERM:
logger.InfoContext(ctx, "Received SIGTERM, shutting down forcefully...")
logger.WarnContext(ctx, "best effort graceful shutdown, interrupting the job as soon as possible...")
serviceCancel()
case syscall.SIGQUIT:
logger.InfoContext(ctx, "Received SIGQUIT, shutting down gracefully...")
logger.InfoContext(ctx, "graceful shutdown, waiting for jobs to finish...")
}
}
}()
Expand Down
27 changes: 0 additions & 27 deletions plugins/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,33 +251,6 @@ func Run(ctx context.Context, logger *slog.Logger) {
for _, workflowRunJob := range allWorkflowRunJobDetails {
ctx = setLoggingContext(ctx, workflowRunJob)

logger.InfoContext(ctx, "handling anka workflow run job 1")
time.Sleep(2 * time.Second)
if ctx.Err() != nil {
logger.InfoContext(ctx, "ctx.Err 1")
return
}
logger.InfoContext(ctx, "handling anka workflow run job 2")
time.Sleep(2 * time.Second)
if ctx.Err() != nil {
logger.InfoContext(ctx, "ctx.Err 2")
return
}
logger.InfoContext(ctx, "handling anka workflow run job 3")
time.Sleep(2 * time.Second)
if ctx.Err() != nil {
logger.InfoContext(ctx, "ctx.Err 3")
return
}
logger.InfoContext(ctx, "handling anka workflow run job 4")
time.Sleep(2 * time.Second)
if ctx.Err() != nil {
logger.InfoContext(ctx, "ctx.Err 4")
return
}

return

// Check if the job is already running, and ensure in DB to prevent other runners from getting it
uniqueKey := fmt.Sprintf("%s:%s", workflowRunJob.RunID, workflowRunJob.UniqueID)
ctx = dbFunctions.UpdateUniqueRunKey(ctx, uniqueKey)
Expand Down

0 comments on commit 7e26588

Please sign in to comment.