qj|dZddlZddlZddlmZddlmZmZeje Z Gddej Z dS)zBase service manager plugin. Provides the shared start/stop/enable/disable logic that product-specific service managers (imav, im360) inherit from. N)utils)messagespluginsceZdZdZdZdZejej j dej j fdZ e j d dZdS) BaseServiceManageruBase service manager: start/stop services based on config changes. Subclasses populate ``_services`` (list of async check callables) and ``_units`` (dict of name → unitctl) in their ``__init__``. cRtj|_g|_i|_dSN)asyncioLock_lock _services_units)selfs \/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/plugins/service_manager.py__init__zBaseServiceManager.__init__s!\^^  c>K|jD]}|d{VdSr )r )rservices r!_ensure_consistent_services_statez4BaseServiceManager._ensure_consistent_services_states:~  G'))OOOOOOOO  rmessage_ignoredcK|j4d{V|d{Vdddd{VdS#1d{VswxYwYdSr )r r)rrs ron_config_updatez#BaseServiceManager.on_config_update s: ; ; ; ; ; ; ; ;88:: : : : : : : : ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s> A AFcK|d{V}||ur|rTtd||dd{Vtd|dStd||dd{Vtd|dS|r9|r9|d{Vtd|dSdSdS)NzA%s is enabled in the config but it is not running. Enabling it...T)nowz Enabled %szB%s is not enabled in the config but it is running. Disabling it...z Disabled %sz#Reloading %s after config update...) is_activeloggerinfoenabledisablereload)runitctl service_nameshould_be_runningr is_runnings r_ensure_service_statusz)BaseServiceManager._ensure_service_status'si#,,........ . . .  9 /  nnn......... L,77777 0  oo$o///////// M<88888 f nn&&&&&&&&& 9<    rN)F)__name__ __module__ __qualname____doc__rrrexpectr MessageType ConfigUpdaterrlog_error_and_ignorer%rrrrs  W^H(566;'3@;;;76;  U!!?D"!rr) r)r loggingdefence360agentrdefence360agent.contractsrr getLoggerr&r MessageSinkrr.rrr4s !!!!!!77777777  8 $ $22222,22222r