@@ -1640,6 +1640,14 @@ public void applyConfig(Configuration config, boolean reindex) {
1640
1640
config .refreshDateForLastIndexRun ();
1641
1641
}
1642
1642
1643
+ // start/stop the watchdog if necessarry
1644
+ if (isAuthorizationWatchdog () && config .getPluginDirectory () != null ) {
1645
+ startWatchDogService (new File (config .getPluginDirectory ()));
1646
+ } else {
1647
+ stopWatchDogService ();
1648
+ }
1649
+
1650
+ // set the new plugin directory and reload the authorization framework
1643
1651
getAuthorizationFramework ().setPluginDirectory (config .getPluginDirectory ());
1644
1652
getAuthorizationFramework ().reload ();
1645
1653
}
@@ -1766,10 +1774,12 @@ protected void handleMessage(Message m, final OutputStream output) throws IOExce
1766
1774
* @param directory root directory for plugins
1767
1775
*/
1768
1776
public void startWatchDogService (File directory ) {
1777
+ stopWatchDogService ();
1769
1778
if (directory == null || !directory .isDirectory () || !directory .canRead ()) {
1770
1779
LOGGER .log (Level .INFO , "Watch dog cannot be started - invalid directory: {0}" , directory );
1771
1780
return ;
1772
1781
}
1782
+ LOGGER .log (Level .INFO , "Starting watchdog in: {0}" , directory );
1773
1783
watchDogThread = new Thread (new Runnable () {
1774
1784
@ Override
1775
1785
public void run () {
@@ -1781,11 +1791,12 @@ public void run() {
1781
1791
@ Override
1782
1792
public FileVisitResult postVisitDirectory (Path d , IOException exc ) throws IOException {
1783
1793
// attach monitor
1794
+ LOGGER .log (Level .FINEST , "Watchdog registering {0}" , d );
1784
1795
d .register (watchDogWatcher , ENTRY_CREATE , ENTRY_DELETE , ENTRY_MODIFY );
1785
1796
return CONTINUE ;
1786
1797
}
1787
1798
});
1788
-
1799
+
1789
1800
LOGGER .log (Level .INFO , "Watch dog started {0}" , directory );
1790
1801
while (!Thread .currentThread ().isInterrupted ()) {
1791
1802
final WatchKey key ;
@@ -1815,9 +1826,10 @@ public FileVisitResult postVisitDirectory(Path d, IOException exc) throws IOExce
1815
1826
}
1816
1827
}
1817
1828
} catch (InterruptedException | IOException ex ) {
1829
+ LOGGER .log (Level .FINEST , "Watchdog finishing (exiting)" , ex );
1818
1830
Thread .currentThread ().interrupt ();
1819
1831
}
1820
- LOGGER .log (Level .INFO , "Watchdog finishing (exiting)" );
1832
+ LOGGER .log (Level .FINER , "Watchdog finishing (exiting)" );
1821
1833
}
1822
1834
}, "watchDogService" );
1823
1835
watchDogThread .start ();
@@ -1831,17 +1843,18 @@ public void stopWatchDogService() {
1831
1843
try {
1832
1844
watchDogWatcher .close ();
1833
1845
} catch (IOException ex ) {
1834
- LOGGER .log (Level .INFO , "Cannot close WatchDogService: " , ex );
1846
+ LOGGER .log (Level .WARNING , "Cannot close WatchDogService: " , ex );
1835
1847
}
1836
1848
}
1837
1849
if (watchDogThread != null ) {
1838
1850
watchDogThread .interrupt ();
1839
1851
try {
1840
1852
watchDogThread .join ();
1841
1853
} catch (InterruptedException ex ) {
1842
- LOGGER .log (Level .INFO , "Cannot join WatchDogService thread: " , ex );
1854
+ LOGGER .log (Level .WARNING , "Cannot join WatchDogService thread: " , ex );
1843
1855
}
1844
1856
}
1857
+ LOGGER .log (Level .INFO , "Watchdog stoped" );
1845
1858
}
1846
1859
1847
1860
public void startExpirationTimer () {
0 commit comments