title: Spring Boot apps keep restarting on App Engine Flexible
body: <p>I have a couple of Spring Boot services that work perfectly locally but they restart after random time on Google App Engine Flexible. These services use google Cloud SQL and Pub/Sub with help of the Spring Boot libraries.</p>
  
  <p>When I deploy the services they work fine, but after a while they get restarted by App Engine. I hooked them up to an instance of Spring Boot admin and I can't see anything strange in the heap or disk space or any of these. Sometimes they reboot after a few hours, sometimes faster.</p>
  
  <p>I tried bumping the logging to trace logging and it seems the services get restarted faster.</p>
  
  <p>I also noticed that the healthcheck gets called a lot, even though the default configuration of the healthcheck says it should be 5 mins and a couple of failed consecutive healthchecks <a href="https://cloud.google.com/appengine/docs/flexible/custom-runtimes/configuring-your-app-with-app-yaml" rel="nofollow noreferrer">google app yaml config</a>. But I never see any failed healthchecks in the logs.</p>
  
  <p>The thing I see is that the healthchecks go well (200 reply), and then suddenly the logging stops, and a couple of minutes later i see </p>
  
  <pre><code>Start command: java -showversion -agentpath:/opt/cdbg/cdbg_java_agent.so=--log_dir
  </code></pre>
  
  <p>which means that app engine is trying to start the app again.</p>
  
  <p>The app.yaml looks like:
  <code>
  runtime: java
  env: flex
  service: x-service
  resources:
    memory_gb: 1.0
  automatic_scaling:
    min_num_instances: 1
    max_num_instances: 2
  env_variables:
    SPRING_PROFILES_ACTIVE: "dev"
  liveness_check:
    path: "/actuator/health"
  readiness_check:
    path: "/actuator/health"
  </code></p>