mirror of
https://github.com/hibiken/asynq.git
synced 2025-07-01 10:53:39 +08:00
fix: add queue after server stopped
This commit is contained in:
parent
8d2955efc1
commit
a05cbd2e38
@ -810,15 +810,14 @@ func (srv *Server) AddQueue(qname string, priority, concurrency int) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
srv.queues[qname] = priority
|
|
||||||
|
|
||||||
srv.state.mu.Lock()
|
srv.state.mu.Lock()
|
||||||
state := srv.state.value
|
state := srv.state.value
|
||||||
srv.state.mu.Unlock()
|
|
||||||
if state == srvStateNew || state == srvStateClosed {
|
if state == srvStateNew || state == srvStateClosed {
|
||||||
srv.queues[qname] = priority
|
srv.queues[qname] = priority
|
||||||
|
srv.state.mu.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
srv.state.mu.Unlock()
|
||||||
|
|
||||||
srv.logger.Info("restart server...")
|
srv.logger.Info("restart server...")
|
||||||
srv.forwarder.shutdown()
|
srv.forwarder.shutdown()
|
||||||
@ -832,6 +831,8 @@ func (srv *Server) AddQueue(qname string, priority, concurrency int) {
|
|||||||
srv.heartbeater.shutdown()
|
srv.heartbeater.shutdown()
|
||||||
srv.wg.Wait()
|
srv.wg.Wait()
|
||||||
|
|
||||||
|
srv.queues[qname] = priority
|
||||||
|
|
||||||
qnames := make([]string, 0, len(srv.queues))
|
qnames := make([]string, 0, len(srv.queues))
|
||||||
for q := range srv.queues {
|
for q := range srv.queues {
|
||||||
qnames = append(qnames, q)
|
qnames = append(qnames, q)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user