@@ -69,12 +69,6 @@ public class Health
6969 */
7070 private static final String ROOM_NAME_PREFIX = "__jicofo-health-check" ;
7171
72- /**
73- * Config property to control health checks:
74- * <li>true - enabled</li>
75- * <li>false - disabled</li>
76- * <li>(null - not set) - auto enable on first REST request(default)</li>
77- */
7872 private static final String ENABLE_HEALTH_CHECKS_PNAME
7973 = "org.jitsi.jicofo.health.ENABLE_HEALTH_CHECKS" ;
8074
@@ -85,10 +79,9 @@ public class Health
8579
8680 /**
8781 * Whether internal health checks are enabled. If not enabled, the rest
88- * API will always return 500 error. If {@link #ENABLE_HEALTH_CHECKS_PNAME}
89- * is not set then the first request will auto enable them.
82+ * API will always return 200.
9083 */
91- private Boolean enabled = null ;
84+ private boolean enabled = false ;
9285
9386 /**
9487 * FIXME: Temporary override for max health check duration.
@@ -109,24 +102,16 @@ public void start(BundleContext bundleContext)
109102 ConfigurationService cfg
110103 = ServiceUtils2 .getService (
111104 bundleContext , ConfigurationService .class );
105+ enabled = cfg != null && cfg .getBoolean (ENABLE_HEALTH_CHECKS_PNAME , false );
112106
113- String enableHealthChecksStr
114- = cfg .getString (ENABLE_HEALTH_CHECKS_PNAME );
115-
116- enabled = enableHealthChecksStr != null
117- ? "true" .equalsIgnoreCase (enableHealthChecksStr )
118- : null ;
119-
120- if (enabled == null )
121- {
122- logger .info (
123- "org.jitsi.jicofo.health.ENABLE_HEALTH_CHECKS" +
124- " is not set - the health checks will auto enable on"
125- + " the first health REST request" );
126- }
127- else if (enabled == false )
107+ if (!enabled )
128108 {
129- logger .warn ("Internal health checks are disabled." );
109+ logger .info ("Internal health checks are disabled. No checks will "
110+ + "be performed, but the REST API will always return 200." );
111+ this .setInterval (Duration .ofMillis (Long .MAX_VALUE ));
112+
113+ // Trigger a single check, so a successful result is cached.
114+ run ();
130115 }
131116
132117 focusManager
@@ -147,41 +132,14 @@ public void stop(BundleContext bundleContext)
147132 }
148133
149134 @ Override
150- public Exception getResult ()
151- {
152- // The very first request will block when enabled == null to avoid
153- // running twice
154- synchronized (this )
155- {
156- if (enabled == null )
157- {
158- logger .info (
159- "Auto-enabling health checks - " +
160- "org.jitsi.jicofo.health.ENABLE_HEALTH_CHECKS not set" );
161- enabled = true ;
162- // Must initialize or will fail the first check with:
163- // "No health checks performed recently"
164- run ();
165- }
166- }
167- return super .getResult ();
168- }
169-
170- @ Override
171- public void run ()
135+ public void performCheck ()
136+ throws Exception
172137 {
173- // Block the periodic runnable if not enabled
174- if (enabled == null || enabled == false )
138+ if (!enabled )
175139 {
176140 return ;
177141 }
178- super .run ();
179- }
180142
181- @ Override
182- public void performCheck ()
183- throws Exception
184- {
185143 Objects .requireNonNull (focusManager , "FocusManager is not set." );
186144
187145 long start = System .currentTimeMillis ();
0 commit comments