@@ -130,46 +130,69 @@ def verdi_status(print_traceback: bool, no_rmq: bool) -> None:
130130 version = 3 ,
131131 )
132132
133- # Getting the broker status
133+ # Getting the daemon and broker status
134134 broker = manager .get_broker ()
135135
136136 if broker :
137- try :
138- broker .get_communicator ()
139- except Exception as exc :
140- message = f'Unable to connect to broker: { broker } '
141- print_status (ServiceStatus .ERROR , 'broker' , message , exception = exc , print_traceback = print_traceback )
142- exit_code = ExitCode .CRITICAL
143- else :
144- print_status (ServiceStatus .UP , 'broker' , str (broker ))
145- finally :
146- broker .close ()
147- else :
137+ from aiida .brokers .zmq .broker import ZmqBroker
138+
139+ # For RabbitMQ: verify broker connectivity as a separate status line
140+ # For ZMQ: broker info is shown alongside the daemon status below
141+ if not isinstance (broker , ZmqBroker ):
142+ try :
143+ broker .get_communicator ()
144+ except Exception as exc :
145+ message = f'Unable to connect to broker: { broker } '
146+ print_status (ServiceStatus .ERROR , 'broker' , message , exception = exc , print_traceback = print_traceback )
147+ exit_code = ExitCode .CRITICAL
148+ else :
149+ print_status (ServiceStatus .UP , 'broker' , str (broker ))
150+ finally :
151+ broker .close ()
152+
153+ if not broker :
148154 print_status (
149155 ServiceStatus .WARNING ,
150156 'broker' ,
151157 f'No broker defined for this profile: certain functionality not available.\n See { URL_NO_BROKER } ' ,
152158 )
153-
154- # Getting the daemon status
155- try :
156- status = manager .get_daemon_client ().get_status ()
157- except ConfigurationError :
158159 print_status (
159160 ServiceStatus .WARNING ,
160161 'daemon' ,
161- 'No broker defined for this profile: daemon is not available.' ,
162+ f 'No broker defined for this profile: daemon is not available. See { URL_NO_BROKER } ' ,
162163 )
163- except DaemonNotRunningException as exception :
164- print_status (ServiceStatus .WARNING , 'daemon' , str (exception ))
165- except DaemonException as exception :
166- print_status (ServiceStatus .ERROR , 'daemon' , str (exception ))
167- except Exception as exception :
168- message = 'Error getting daemon status'
169- print_status (ServiceStatus .ERROR , 'daemon' , message , exception = exception , print_traceback = print_traceback )
170- exit_code = ExitCode .CRITICAL
171164 else :
172- print_status (ServiceStatus .UP , 'daemon' , f'Daemon is running with PID { status ["pid" ]} ' )
165+ try :
166+ daemon_status = manager .get_daemon_client ().get_status ()
167+ except ConfigurationError :
168+ print_status (
169+ ServiceStatus .WARNING ,
170+ 'daemon' ,
171+ f'No broker defined for this profile: daemon is not available. See { URL_NO_BROKER } ' ,
172+ )
173+ except DaemonNotRunningException as exception :
174+ print_status (ServiceStatus .WARNING , 'daemon' , str (exception ))
175+ except DaemonException as exception :
176+ print_status (ServiceStatus .ERROR , 'daemon' , str (exception ))
177+ except Exception as exception :
178+ message = 'Error getting daemon status'
179+ print_status (ServiceStatus .ERROR , 'daemon' , message , exception = exception , print_traceback = print_traceback )
180+ exit_code = ExitCode .CRITICAL
181+ else :
182+ daemon_msg = f'Daemon is running with PID { daemon_status ["pid" ]} '
183+ # Append broker info for managed brokers (e.g., ZMQ)
184+
185+ if isinstance (broker , ZmqBroker ):
186+ if broker .is_running ():
187+ status_info = broker .get_service_status ()
188+ if status_info :
189+ broker_pid = status_info .get ('pid' , '?' )
190+ pending = status_info .get ('pending_tasks' , 0 )
191+ processing = status_info .get ('processing_tasks' , 0 )
192+ daemon_msg += f', Broker PID { broker_pid } [{ pending } pending, { processing } processing]'
193+ else :
194+ daemon_msg += ', Broker is NOT running'
195+ print_status (ServiceStatus .UP , 'daemon' , daemon_msg )
173196
174197 # Note: click does not forward return values to the exit code, see https://github.com/pallets/click/issues/747
175198 if exit_code != ExitCode .SUCCESS :
0 commit comments