mirror of https://github.com/reiseburo/offtopic
Add a basic health check and make sure `./gradlew run` actually stands up the server
This commit is contained in:
parent
4228871e19
commit
2cb37364c0
|
@ -1,3 +1,4 @@
|
|||
build/
|
||||
.gradle/
|
||||
*.sw*
|
||||
.idea/
|
||||
|
|
|
@ -4,6 +4,9 @@ plugins {
|
|||
id 'codenarc'
|
||||
}
|
||||
|
||||
description = 'Offtopic is for watching Kafka topics'
|
||||
mainClassName = 'offtopic.OfftopicApp'
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
@ -29,3 +32,7 @@ test {
|
|||
codenarc {
|
||||
configFile = file("${projectDir}/gradle/codenarc.xml")
|
||||
}
|
||||
|
||||
run {
|
||||
args 'server', 'offtopic.example.yml'
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
// Project settings
|
||||
version=0.3.0
|
||||
group=com.github.rtyler
|
||||
|
||||
// Build settings
|
||||
dropwizardVersion=0.8.1
|
||||
groovyVersion=2.4.3
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
logging:
|
||||
level: INFO
|
|
@ -4,12 +4,15 @@ import io.dropwizard.Application
|
|||
import io.dropwizard.setup.Bootstrap
|
||||
import io.dropwizard.setup.Environment
|
||||
|
||||
import groovy.transform.TypeChecked
|
||||
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
/**
|
||||
* Primary application instance for Dropwizard
|
||||
*/
|
||||
@TypeChecked
|
||||
class OfftopicApp extends Application<OfftopicConfig> {
|
||||
/**
|
||||
* Primary logger instance for the app
|
||||
|
@ -28,6 +31,8 @@ class OfftopicApp extends Application<OfftopicConfig> {
|
|||
@Override
|
||||
void run(OfftopicConfig configuration, Environment environment) throws Exception {
|
||||
this.logger.info("Starting the Offtopic application")
|
||||
|
||||
environment.healthChecks().register('sanity', new offtopic.health.BasicHealth())
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package offtopic.health
|
||||
|
||||
import com.codahale.metrics.health.HealthCheck
|
||||
import com.codahale.metrics.health.HealthCheck.Result
|
||||
|
||||
/**
|
||||
* A basic healthcheck to ensure that the application is at least executing properly
|
||||
*/
|
||||
class BasicHealth extends HealthCheck {
|
||||
@Override
|
||||
protected Result check() {
|
||||
return Result.healthy()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package offtopic.resources
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings('EmptyClass')
|
||||
class MainResource {
|
||||
}
|
Loading…
Reference in New Issue