ソースを参照

fix config restart checking

Jason Rivard 8 年 前
コミット
cc33cf12ab

+ 15 - 0
src/main/java/password/pwm/ws/server/rest/RestAppDataServer.java

@@ -155,6 +155,21 @@ public class RestAppDataServer extends AbstractRestServer {
         return restResultBean.asJsonResponse();
         return restResultBean.asJsonResponse();
     }
     }
 
 
+    @GET
+    @Path("/ping")
+    @Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8")
+    public Response doPingRequest() {
+        final RestRequestBean restRequestBean;
+        try {
+            restRequestBean = RestServerHelper.initializeRestRequest(request, response, ServicePermissions.PUBLIC, null);
+        } catch (PwmUnrecoverableException e) {
+            return RestResultBean.fromError(e.getErrorInformation()).asJsonResponse();
+        }
+
+        final String startupTime = restRequestBean.getPwmApplication().getStartupTime().toString();
+        return new RestResultBean(new HashMap<>(Collections.singletonMap("time",startupTime))).asJsonResponse();
+    }
+
     @GET
     @GET
     @Path("/session")
     @Path("/session")
     @Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8")
     @Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8")

+ 3 - 4
src/main/webapp/public/resources/js/configmanager.js

@@ -52,8 +52,8 @@ PWM_CONFIG.waitForRestart=function(options) {
     console.log("beginning request to determine application status: ");
     console.log("beginning request to determine application status: ");
     var loadFunction = function(data) {
     var loadFunction = function(data) {
         try {
         try {
-            var serverStartTime = data['data']['PWM_GLOBAL']['startupTime'];
-            if (serverStartTime != PWM_GLOBAL['startupTime']) {
+            var serverStartTime = data['time'];
+            if (serverStartTime !== PWM_GLOBAL['startupTime']) {
                 console.log("application appears to be restarted, redirecting to context url: ");
                 console.log("application appears to be restarted, redirecting to context url: ");
                 var redirectUrl = 'location' in options ? options['location'] : '/';
                 var redirectUrl = 'location' in options ? options['location'] : '/';
                 PWM_MAIN.goto(redirectUrl);
                 PWM_MAIN.goto(redirectUrl);
@@ -72,8 +72,7 @@ PWM_CONFIG.waitForRestart=function(options) {
         }, 3000);
         }, 3000);
         console.log('Waiting for server restart, unable to contact server: ' + error);
         console.log('Waiting for server restart, unable to contact server: ' + error);
     };
     };
-    var url = PWM_GLOBAL['url-restservice'] + "/app-data/client?checkForRestart=true";
-    url = PWM_MAIN.addParamToUrl(url,'pageUrl',window.location.href);
+    var url = PWM_GLOBAL['url-restservice'] + "/app-data/ping";
     PWM_MAIN.ajaxRequest(url,loadFunction,{errorFunction:errorFunction,method:'GET'});
     PWM_MAIN.ajaxRequest(url,loadFunction,{errorFunction:errorFunction,method:'GET'});
 };
 };