Before you begin
Running Swift and Kitura on GAE Flex is as easy as:
git clone https://github.com/mcdonamp/kitura-flex cd kitura-flex gcloud app deploy gcloud app browse
App code is available in
Sources/ and contains
main.swift is the application entry point. It initializes the controller, and starts
the app server.
Controller.swift contains all the routes, including the GAE specific
routes. New routes can be added here, or in additional files and called from here.
An area for future improvement would be to package the GAE routes as middleware similar to how Cloud Foundry is implemented in the original sample.
Logs are output to Google Cloud Logging in two phases:
- Container Builder > $build_id
- GAE Application > $service_name > $version
The first set of logs are useful for debugging the container build and deployment, while the second are used for monitoring the app in production. Any log statements from your Kitura app will be forwarded to Cloud Logging.
Continue reading the docs for more info on application logging.
Per Building GAE Flex Custom Runtimes
your application should handle certain lifecycle events, such as
// Respond to GAE Health checks (mandatory) router.all("/_ah/health", handler: health) // Respond to GAE start, stop requests (optional) router.all("/_ah/start", handler: start) router.all("/_ah/stop", handler: stop)
Continue reading the docs for more info on lifecycle events.
app.yaml currently has the bare minimum required for a GAE Flex app, but can
be configured to do far more than run an app. You can use
app.yaml to specify
resource allocation, configure health checks, and tune autoscaling params.
Continue reading the docs for more info on