mirror of
https://github.com/keven1024/015.git
synced 2026-05-27 07:29:37 +00:00
25 lines
500 B
Go
25 lines
500 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"worker/internal/tasks"
|
|
"worker/internal/utils"
|
|
|
|
"github.com/hibiken/asynq"
|
|
"github.com/spf13/cast"
|
|
)
|
|
|
|
func main() {
|
|
srv := asynq.NewServer(
|
|
utils.RedisURI2AsynqOpt(utils.GetEnv("REDIS_URL")),
|
|
asynq.Config{Concurrency: cast.ToInt(utils.GetEnvWithDefault("WORKER_CONCURRENCY", "4"))},
|
|
)
|
|
|
|
mux := asynq.NewServeMux()
|
|
mux.HandleFunc("image:compress", tasks.CompressImage)
|
|
|
|
if err := srv.Run(mux); err != nil {
|
|
log.Fatalf("could not run server: %v", err)
|
|
}
|
|
}
|