I made a discord bot I'm trying to host on appengine, it runs well however when left idly for more than 30 minutes, appengine shuts the instance down due to -what i believe the issue is- automatic scaling in which app engine shuts down instances that are inactive in traffic to cut costs. According to the java docs, you need to set your app's appengine-web.xml file in target/project-1.0/WEB-INF/appengine-web.xml to manual-scaling which also controls the amount of instances that instantiate. But this doesn't seem to have fixed the issue. I'm barely using any traffic and I checked my instance's statistics, its simply shutting down due to inactivity.
The way I detach from my console is running my java app via java -jar project-1.0.jar &. The & detaches and makes it run by itself (which is the case).
30 minutes after activating the app and closing the console, the app shuts down as a result of automatic-scaling.
this is my appengine-web.xml:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>wizardry-discord-bot</application><!-- unused for Cloud SDK based tooling -->
<version>1</version><!-- unused for Cloud SDK based tooling -->
<threadsafe>true</threadsafe>
<runtime>java8</runtime>
<manual-scaling>
<instances>1</instances>
</manual-scaling>
</appengine-web-app>
Since this didn't work, The docs were unclear so I added this as well to my app.yaml in src/main/appengine/app.yaml as did many samples I've read. Again, docs unclear but they said I can specify manual-scaling here as well. I'm lost at this point as to what is what and which is where.
# [START_EXCLUDE]
# Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# [END_EXCLUDE]
# [START runtime]
runtime: custom
env: flex
handlers:
- url: /.*
script: this field is required, but ignored
runtime_config: # Optional
jdk: openjdk8
server: jetty9
manual_scaling:
instances: 1
# [END runtime]
So am i doing something wrong here? I'm new to google cloud in general. Kind of lost.
EDIT: Further more: The docs say to run mvn appengine:deploy to actually run your code instead of compiling and java -jar'ing it. https://cloud.google.com/java/getting-started/hello-world However, when I do run the command: https://hastebin.com/magizutuho.sql
App Engine
->Versions
page. - Dan Cornilescu