Commit 67347869 by Johannes Stelzer

Merge Pull Request #24 Enable contextPath

parents da6cce71 aae9cc78
...@@ -4,5 +4,4 @@ info.version=@pom.version@ ...@@ -4,5 +4,4 @@ info.version=@pom.version@
info.stage=test info.stage=test
logging.file=/tmp/log.log logging.file=/tmp/log.log
spring.application.name=@pom.artifactId@ spring.application.name=@pom.artifactId@
spring.boot.admin.url=http://localhost:8080 spring.boot.admin.url=http://localhost:8080
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
<title>Spring Boot Admin</title> <title>Spring Boot Admin</title>
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width"> <meta name="viewport" content="width=device-width">
<link rel="shortcut icon" type="image/x-icon" href="/img/favicon.png" /> <link rel="shortcut icon" type="image/x-icon" href="img/favicon.png" />
<link href="https://fonts.googleapis.com/css?family=Varela+Round|Montserrat:400,700" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Varela+Round|Montserrat:400,700" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="/webjars/bootstrap/${bootstrap.version}/css/bootstrap.min.css" /> <link rel="stylesheet" type="text/css" href="webjars/bootstrap/${bootstrap.version}/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/webjars/nvd3/${nvd3.version}/nv.d3.min.css" /> <link rel="stylesheet" type="text/css" href="webjars/nvd3/${nvd3.version}/nv.d3.min.css" />
<link rel="stylesheet" type="text/css" href="/styles/main.css" /> <link rel="stylesheet" type="text/css" href="styles/main.css" />
</head> </head>
<body ng-app="springBootAdmin"> <body ng-app="springBootAdmin">
<script type="text/javascript"> <script type="text/javascript">
...@@ -47,21 +47,21 @@ ...@@ -47,21 +47,21 @@
</div> </div>
</footer> </footer>
</div> </div>
<script src="/webjars/jquery/${jquery.version}/jquery.min.js"></script> <script src="webjars/jquery/${jquery.version}/jquery.min.js"></script>
<script src="/webjars/angularjs/${angularjs.version}/angular.min.js"></script> <script src="webjars/angularjs/${angularjs.version}/angular.min.js"></script>
<script src="/webjars/bootstrap/${bootstrap.version}/js/bootstrap.min.js"></script> <script src="webjars/bootstrap/${bootstrap.version}/js/bootstrap.min.js"></script>
<script src="/webjars/angularjs/${angularjs.version}/angular-resource.min.js"></script> <script src="webjars/angularjs/${angularjs.version}/angular-resource.min.js"></script>
<script src="/webjars/angularjs/${angularjs.version}/angular-route.min.js"></script> <script src="webjars/angularjs/${angularjs.version}/angular-route.min.js"></script>
<script src="/webjars/angular-ui-router/0.2.10/angular-ui-router.min.js"></script> <script src="webjars/angular-ui-router/0.2.10/angular-ui-router.min.js"></script>
<script src="/webjars/angular-ui-bootstrap/${angular-ui-bootstrap.version}/ui-bootstrap.min.js"></script> <script src="webjars/angular-ui-bootstrap/${angular-ui-bootstrap.version}/ui-bootstrap.min.js"></script>
<script src="/webjars/angular-ui-bootstrap/${angular-ui-bootstrap.version}/ui-bootstrap-tpls.min.js"></script> <script src="webjars/angular-ui-bootstrap/${angular-ui-bootstrap.version}/ui-bootstrap-tpls.min.js"></script>
<script src="/webjars/d3js/${d3js.version}/d3.min.js"></script> <script src="webjars/d3js/${d3js.version}/d3.min.js"></script>
<script src="/webjars/nvd3/${nvd3.version}/nv.d3.min.js"></script> <script src="webjars/nvd3/${nvd3.version}/nv.d3.min.js"></script>
<script src="/webjars/angularjs-nvd3-directives/0.0.7/angularjs-nvd3-directives.js"></script> <script src="webjars/angularjs-nvd3-directives/0.0.7/angularjs-nvd3-directives.js"></script>
<script src="/webjars/jolokia.js/${jolokia-js.version}/jolokia.js"></script> <script src="webjars/jolokia.js/${jolokia-js.version}/jolokia.js"></script>
<script src="/scripts/app.js"></script> <script src="scripts/app.js"></script>
<script src="/scripts/controllers/controllers.js"></script> <script src="scripts/controllers/controllers.js"></script>
<script src="/scripts/services/services.js"></script> <script src="scripts/services/services.js"></script>
<script src="/scripts/filters/filters.js"></script> <script src="scripts/filters/filters.js"></script>
</body> </body>
</html> </html>
...@@ -92,5 +92,4 @@ angular.module('springBootAdmin', [ ...@@ -92,5 +92,4 @@ angular.module('springBootAdmin', [
.run(function ($rootScope, $state, $stateParams, $log) { .run(function ($rootScope, $state, $stateParams, $log) {
$rootScope.$state = $state; $rootScope.$state = $state;
$rootScope.$stateParams = $stateParams; $rootScope.$stateParams = $stateParams;
$rootScope.springBootAdminServerUrl = window.location.protocol + '//' + window.location.host;
}); });
...@@ -18,22 +18,22 @@ ...@@ -18,22 +18,22 @@
angular.module('springBootAdmin.services', ['ngResource']) angular.module('springBootAdmin.services', ['ngResource'])
.factory('Applications', ['$resource', function($resource) { .factory('Applications', ['$resource', function($resource) {
return $resource( return $resource(
'/api/applications', {}, { 'api/applications', {}, {
query: { method:'GET', isArray:true } query: { method:'GET', isArray:true }
}); });
} }
]) ])
.factory('Application', ['$resource', function($resource) { .factory('Application', ['$resource', function($resource) {
return $resource( return $resource(
'/api/application/:id', {}, { 'api/application/:id', {}, {
query: { method:'GET'}, query: { method:'GET'},
remove: {method: 'DELETE'} remove: {method:'DELETE'}
}); });
} }
]) ])
.service('ApplicationOverview', ['$http', function($http) { .service('ApplicationOverview', ['$http', function($http) {
this.getInfo = function(app) { this.getInfo = function(app) {
return $http.get(app.url + '/info').success(function(response) { return $http.get(app.url + '/info/').success(function(response) {
app.version = response.version; app.version = response.version;
delete response.version; delete response.version;
app.info = response; app.info = response;
...@@ -42,7 +42,7 @@ angular.module('springBootAdmin.services', ['ngResource']) ...@@ -42,7 +42,7 @@ angular.module('springBootAdmin.services', ['ngResource'])
}); });
} }
this.getHealth = function(app) { this.getHealth = function(app) {
return $http.get(app.url + '/health').success(function (response) { return $http.get(app.url + '/health/').success(function (response) {
app.status = response.status; app.status = response.status;
}).error(function (response, httpStatus) { }).error(function (response, httpStatus) {
if (httpStatus === 503) { if (httpStatus === 503) {
...@@ -55,7 +55,7 @@ angular.module('springBootAdmin.services', ['ngResource']) ...@@ -55,7 +55,7 @@ angular.module('springBootAdmin.services', ['ngResource'])
}); });
} }
this.getLogfile = function(app) { this.getLogfile = function(app) {
return $http.head(app.url + '/logfile').success(function(response) { return $http.head(app.url + '/logfile/').success(function(response) {
app.providesLogfile = true; app.providesLogfile = true;
}).error(function() { }).error(function() {
app.providesLogfile = false; app.providesLogfile = false;
...@@ -64,16 +64,16 @@ angular.module('springBootAdmin.services', ['ngResource']) ...@@ -64,16 +64,16 @@ angular.module('springBootAdmin.services', ['ngResource'])
}]) }])
.service('ApplicationDetails', ['$http', function($http) { .service('ApplicationDetails', ['$http', function($http) {
this.getInfo = function(app) { this.getInfo = function(app) {
return $http.get(app.url + '/info'); return $http.get(app.url + '/info/');
} }
this.getMetrics = function(app) { this.getMetrics = function(app) {
return $http.get(app.url + '/metrics'); return $http.get(app.url + '/metrics/');
} }
this.getEnv = function(app) { this.getEnv = function(app) {
return $http.get(app.url + '/env'); return $http.get(app.url + '/env/');
} }
this.getHealth = function(app) { this.getHealth = function(app) {
return $http.get(app.url + '/health'); return $http.get(app.url + '/health/');
} }
}]) }])
...@@ -85,15 +85,15 @@ angular.module('springBootAdmin.services', ['ngResource']) ...@@ -85,15 +85,15 @@ angular.module('springBootAdmin.services', ['ngResource'])
for (var j in loggers) { for (var j in loggers) {
requests.push({ type: 'exec', mbean: LOGBACK_MBEAN, operation: 'getLoggerEffectiveLevel', arguments: [ loggers[j].name ] }) requests.push({ type: 'exec', mbean: LOGBACK_MBEAN, operation: 'getLoggerEffectiveLevel', arguments: [ loggers[j].name ] })
} }
return jolokia.bulkRequest(app.url + '/jolokia', requests); return jolokia.bulkRequest(app.url + '/jolokia/', requests);
} }
this.setLoglevel = function(app, logger, level) { this.setLoglevel = function(app, logger, level) {
return jolokia.exec(app.url + '/jolokia', LOGBACK_MBEAN, 'setLoggerLevel' , [ logger, level] ); return jolokia.exec(app.url + '/jolokia/', LOGBACK_MBEAN, 'setLoggerLevel' , [ logger, level] );
} }
this.getAllLoggers = function(app) { this.getAllLoggers = function(app) {
return jolokia.readAttr(app.url + '/jolokia', LOGBACK_MBEAN, 'LoggerList'); return jolokia.readAttr(app.url + '/jolokia/', LOGBACK_MBEAN, 'LoggerList');
} }
}]) }])
.service('ApplicationJMX', ['$rootScope', 'Abbreviator', 'Jolokia', function($rootScope, Abbreviator, jolokia) { .service('ApplicationJMX', ['$rootScope', 'Abbreviator', 'Jolokia', function($rootScope, Abbreviator, jolokia) {
...@@ -156,15 +156,15 @@ angular.module('springBootAdmin.services', ['ngResource']) ...@@ -156,15 +156,15 @@ angular.module('springBootAdmin.services', ['ngResource'])
} }
this.readAllAttr = function(app, bean) { this.readAllAttr = function(app, bean) {
return jolokia.read(app.url + '/jolokia', bean.id) return jolokia.read(app.url + '/jolokia/', bean.id)
} }
this.writeAttr = function(app, bean, attr, val) { this.writeAttr = function(app, bean, attr, val) {
return jolokia.writeAttr(app.url + '/jolokia', bean.id, attr, val); return jolokia.writeAttr(app.url + '/jolokia/', bean.id, attr, val);
} }
this.invoke = function(app, bean, opname, args) { this.invoke = function(app, bean, opname, args) {
return jolokia.exec(app.url + '/jolokia', bean.id, opname, args); return jolokia.exec(app.url + '/jolokia/', bean.id, opname, args);
} }
}]) }])
...@@ -328,6 +328,6 @@ angular.module('springBootAdmin.services', ['ngResource']) ...@@ -328,6 +328,6 @@ angular.module('springBootAdmin.services', ['ngResource'])
}]) }])
.service('ApplicationThreads', ['$http', function($http) { .service('ApplicationThreads', ['$http', function($http) {
this.getDump = function(app) { this.getDump = function(app) {
return $http.get(app.url + '/dump'); return $http.get(app.url + '/dump/');
} }
}]); }]);
...@@ -21,7 +21,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; ...@@ -21,7 +21,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "spring.boot.admin.client", ignoreUnknownFields = false) @ConfigurationProperties(prefix = "spring.boot.admin.client", ignoreUnknownFields = false)
public class AdminClientProperties { public class AdminClientProperties {
@Value("http://#{T(java.net.InetAddress).localHost.canonicalHostName}:${server.port:${management.port:8080}}${management.context-path:/}") @Value("http://#{T(java.net.InetAddress).localHost.canonicalHostName}:${management.port:${server.port:8080}}${server.contextPath:/}${management.context-path:/}")
private String url; private String url;
@Value("${spring.application.name:spring-boot-application}") @Value("${spring.application.name:spring-boot-application}")
......
...@@ -51,10 +51,10 @@ public class SpringBootAdminRegistrator { ...@@ -51,10 +51,10 @@ public class SpringBootAdminRegistrator {
*/ */
public boolean register() { public boolean register() {
Application app = createApplication(); Application app = createApplication();
String adminUrl = adminProps.getUrl() + '/' + adminProps.getContextPath();
try { try {
ResponseEntity<Application> response = template.postForEntity( ResponseEntity<Application> response = template.postForEntity(adminUrl, app, Application.class);
adminProps.getUrl() + '/' + adminProps.getContextPath(), app, Application.class);
if (response.getStatusCode().equals(HttpStatus.CREATED)) { if (response.getStatusCode().equals(HttpStatus.CREATED)) {
LOGGER.info("Application registered itself as {}", response.getBody()); LOGGER.info("Application registered itself as {}", response.getBody());
...@@ -68,7 +68,8 @@ public class SpringBootAdminRegistrator { ...@@ -68,7 +68,8 @@ public class SpringBootAdminRegistrator {
} }
} }
catch (Exception ex) { catch (Exception ex) {
LOGGER.warn("Failed to register application as {} at spring-boot-admin: {}", app, ex.getMessage()); LOGGER.warn("Failed to register application as {} at spring-boot-admin ({}): {}", app, adminUrl,
ex.getMessage());
} }
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment