@@ -364,10 +364,11 @@ def load_transforms
364364 # @param [String] addon_id The addon id, such as "binding-mqtt"
365365 # @param [true,false] wait Wait until OSGi has confirmed the bundle is installed and running before returning.
366366 # @param [String,Array<String>] ready_markers Array of ready marker types to wait for.
367+ # @param [Numeric] ready_timeout Max seconds to wait for ready markers.
367368 # The addon's bundle id is used as the identifier.
368369 # @return [void]
369370 #
370- def install_addon ( addon_id , wait : true , ready_markers : nil )
371+ def install_addon ( addon_id , wait : true , ready_markers : nil , ready_timeout : 30 )
371372 service_filter = "(component.name=org.openhab.core.karafaddons)"
372373 addon_service = OSGi . service ( "org.openhab.core.addon.AddonService" , filter : service_filter )
373374 addon_service . install ( addon_id )
@@ -395,8 +396,19 @@ def install_addon(addon_id, wait: true, ready_markers: nil)
395396 end
396397
397398 rs = OSGi . service ( "org.openhab.core.service.ReadyService" )
399+ deadline = Process . clock_gettime ( Process ::CLOCK_MONOTONIC ) + ready_timeout
400+
398401 loop do
399- break if ready_markers . all? { |rm | rs . ready? ( rm ) }
402+ pending_markers = ready_markers . reject { |rm | rs . ready? ( rm ) }
403+ break if pending_markers . empty?
404+
405+ if Process . clock_gettime ( Process ::CLOCK_MONOTONIC ) >= deadline
406+ pending_marker_text = pending_markers
407+ . map { |rm | "#{ rm . type } (#{ rm . identifier } )" }
408+ . join ( ", " )
409+ logger . warn ( "Timed out waiting for ready markers for #{ addon_id } : #{ pending_marker_text } " )
410+ raise "Timed out after #{ ready_timeout } s waiting for ready markers for #{ addon_id } : #{ pending_marker_text } "
411+ end
400412
401413 sleep 0.25
402414 end
0 commit comments