+
    Qi  c                   s   a  R t0 t R tRtRtRtRtRt^ RIt^ RIt^ RI	t	^ RI
t
^ RIHt ^RIHt  ! R	 R
4      t]! 4       t] ^ k R R ltR# )3Orca's integration with the systemd service managerz$Id$z
$Revision$z$Date$zCopyright (c) 2025 Red HatZLGPLN)GLib)debugc                   s   a  ] tR t^%t o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR	 ltV 3R
 lR lt	V 3R lR lt
RV 3R lR lltV 3R lR ltV 3R lR ltRtV tR# )Systemdr    c                   < V ^8  d   QhRR/#    returnN format__classdict__   "1/usr/lib/python3.14/site-packages/orca/systemd.py__annotate__Systemd.__annotate__(   s     A A$ A    c                sL   R V n         R V n        RV n        \        P                  P                  R4      pV'       d   V^ ,          R8X  d   RVR,          ,           pM)V^ ,          R8X  d   M\        \        P                  R4      h\        P                  ! \        P                  \        P                  \        P                  ,          4      pVP                  V4       W n         \        P                  P                  R4      pV'       d   \        V4      R	,          V n        R # R # )
Ng        ZNOTIFY_SOCKETZ@Z :i   NNZ/zUnsupported NOTIFY_SOCKET typeZWATCHDOG_USEC  )_notify_socket_watchdog_interval
_last_pingosZenvironZgetZOSErrorerrnoZEAFNOSUPPORTsocketZAF_UNIXZ
SOCK_DGRAMZSOCK_CLOEXECZconnectZint)selfZsocket_pathZsockZwatchdog_usecs   &   r   __init__ZSystemd.__init__(   s    48.2!$jjnn_51~$"[_4Q3&e002RSS==1B1BVEXEX1XYDLL%"&

7&)-&8D&@D# r   c                $   < V ^8  d   QhRS[ RR/# )r   messager   N)Zbytesr	   r   r   r   r   >   s     1 1u 1 1r   c                s    V P                   '       dV   \        P                  ! \        P                  RVP	                  R4       2R4       V P                   P                  V4       R# R# )z)Send systemd a raw sd_notify notificationzSYSTEMD: Sending: zutf-8TN)r   r   print_message
LEVEL_INFOZdecodeZsendall)r   r   s   &&r   _notifyZSystemd._notify>   sX       $6w~~g7N6O"PRVX''0 r   c                r   r   r   r	   r   r   r   r   G   s     ! !d !r   c                (    V P                  R4       R# )z;Tell systemd that Orca has finished starting up / reloadings   READY=1Nr   r      &r   notify_readyZSystemd.notify_readyG   s    Z r   c                r   r   r   r	   r   r   r   r   K   s     ' '$ 'r   c                s    \         P                  ! \         P                  4      R,          pRV 2pV P                  VP	                  4       4       R# )z,Tell systemd that Orca has started reloadingr   zRELOADING=1
MONOTONIC_USEC=N)timeZclock_gettime_nsZCLOCK_MONOTONICr   Zencode)r   Zreload_timestampr   s   &  r   notify_reloadingZSystemd.notify_reloadingK   s?    001E1EF$N01A0BCW^^%&r   c                r   r   r   r	   r   r   r   r   Q   s     $ $ $r   c                r   )z'Tell systemd that Orca is shutting downs
   STOPPING=1Nr    r!   r"   r   notify_stoppingZSystemd.notify_stoppingQ   s    ]#r   c                r   r   r   r	   r   r   r   r   U   s     & & &r   c                s\    V P                  R4       \        P                  ! 4       V n        R# )z3Send a watchdog ping and update last-ping timestamps
   WATCHDOG=1N)r   r$   r   r!   r"   r   _ping_watchdogZSystemd._ping_watchdogU   s    ]#))+r   c                r   )r   reasonr   N)Zstrr	   r   r   r   r   Z   s     
" 
"3 
" 
"r   c                s0   V P                   '       g   R# RV 2p\        P                  ! \        P                  VR4       \        P                  ! 4       V P
                  ,
          R,          pW0P                   ^,          8  d   V P                  4        R# R# )z%Tell systemd that Orca is still aliveNzSYSTEMD: notify_alive called. Tr   )r   r   r   r   r$   r   r'   )r   r(   ZmsgZ
elapsed_mss   &&  r   notify_aliveZSystemd.notify_aliveZ   sr     &&&.vh7E,,c48iikDOO3t;
00A55! 6r   c                r   r   r   r	   r   r   r   r   f   s     6 6 6r   c                s   a  S P                   '       g   R# R V 3R llp\        P                  ! S P                   ^,          V\        P                  R7       R# )z?Start regularly sending keepalive pings to the systemd watchdogNc                $    V ^8  d   QhR\         /# r   r   Zboolr
      "r   r   Z,Systemd.start_watchdog.<locals>.__annotate__k   s     	( 	(4 	(r   c                 sD   < S P                  4        \        P                  # )z%Send a keepalive ping to the watchdog)r'   r   ZSOURCE_CONTINUEr!   s   r   _on_watchdog_tickZ1Systemd.start_watchdog.<locals>._on_watchdog_tickk   s    !'''r   )Zpriority)r   r   Ztimeout_addZPRIORITY_HIGH)r   r/   s   f r   start_watchdogZSystemd.start_watchdogf   sE    &&&	( 	( 	00A57H"&"4"4	6r   c                s    < V ^8  d   QhRS[ /# r+   r,   r	   r   r   r   r   {   s     / /D /r   c                s    V P                   RJ# )z7Returns whether or not Orca is being managed by systemdN)r   r!   r"   r   is_systemd_managedZSystemd.is_systemd_managed{   s    ""$..r   )r   r   r   N) )Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__r   r   r#   r%   r&   r'   r)   r0   r1   Z__static_attributes__Z__classdictcell__)r      @r   r   r   %   sd     =A A,1 1! !' '$ $& &

" 
"6 6*/ /r   r   c                r*   r+   )r   r-   r.   r   r   r      s      W r   c                 s    \         # )zReturns the Systemd singleton.)_managerr   r   r   get_managerr6      s    Or   c                s@    V ^8  d   Qh/ ^ \         9   d
   \        ;R&   # )r   r5   )__conditional_annotations__r   r-   r.   r   r   r      s     9 9T  ' U :r   )r7   r3   Z__id__Z__version__Z__date__Z__copyright__Z__license__r   r   r   r$   Zgi.repositoryr   r2   r   r   r5   r6   r   )r7   r4   r   <module>r8      sT   * :,  	    X/ X/t I r   