From 03b02010ed25f034d0f88020cc51d5be04f5d126 Mon Sep 17 00:00:00 2001 From: Jacky Date: Wed, 5 Feb 2025 21:29:43 +0800 Subject: [PATCH] chore: enhance devcontainer and cron job configuration - Add cloc to devcontainer Dockerfile for code line counting - Modify cron job to start cleaning expired auth tokens immediately --- .devcontainer/Dockerfile | 2 +- internal/cron/cron.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 18db34bd..7aca3130 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,7 +2,7 @@ FROM mcr.microsoft.com/devcontainers/base:jammy # Combine installation steps for Nginx and Go to avoid repetitive update/cleanup commands RUN apt-get update && \ - apt-get install -y --no-install-recommends curl gnupg2 ca-certificates lsb-release ubuntu-keyring jq && \ + apt-get install -y --no-install-recommends curl gnupg2 ca-certificates lsb-release ubuntu-keyring jq cloc && \ \ # Configure the Nginx repository curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor > /usr/share/keyrings/nginx-archive-keyring.gpg && \ diff --git a/internal/cron/cron.go b/internal/cron/cron.go index ede41678..630bc0ae 100644 --- a/internal/cron/cron.go +++ b/internal/cron/cron.go @@ -70,7 +70,7 @@ func cleanExpiredAuthToken() { logger.Debug("clean expired auth tokens") q := query.AuthToken _, _ = q.Where(q.ExpiredAt.Lt(time.Now().Unix())).Delete() - }), gocron.WithSingletonMode(gocron.LimitModeWait)) + }), gocron.WithSingletonMode(gocron.LimitModeWait), gocron.JobOption(gocron.WithStartImmediately())) if err != nil { logger.Fatalf("CleanExpiredAuthToken Err: %v\n", err)