Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On Google's app engine (GAE), how can my server tell if it's the default version?

On my Google AppEngine (GAE) server, I'd like to do something like this:

if (thisIsTheDefaultServer)
{
    // behave normally
}
else
{
    // Accept special test-commands, give extra output, etc.
}

is there a way for the server code to determine if it's the current default version?

Thanks!

like image 534
Olie Avatar asked Jul 17 '11 18:07

Olie


People also ask

How do I remove default service from App Engine?

The only way you can delete the default version of your App Engine app is by deleting your project. However, you can stop the default version in the GCP Console. This action shuts down all instances associated with the version. You can restart these instances later if needed.

What is the difference between Google App Engine and Google Compute Engine?

Compute Engine delivers configurable virtual machines running in Google's data centers with access to high-performance networking infrastructure and block storage solutions. App Engine is a fully managed, serverless platform for developing and hosting web applications at scale.

What is the difference between App Engine standard and flexible?

The standard environment can scale from zero instances up to thousands very quickly. In contrast, the flexible environment must have at least one instance running for each active version and can take longer to scale up in response to traffic. Standard environment uses a custom-designed autoscaling algorithm.


1 Answers

There's not currently any way to do this, but you might want to reconsider your requirements. Two alternatives spring to mind:

  1. Switch on the hostname: If it's the bare appspot name or a custom domain name, you're serving as the default version. If it's a version.app.appspot.com name, you may or may not be the default version, but should probably enable the different behavior anyway.
  2. Enable the extra behavior based on whether the user is logged in as an admin or not. This is probably a better idea all around: It makes it easier to debug your production app, and means regular users can't find the alternate version and see stuff they shouldn't.
like image 154
Nick Johnson Avatar answered Sep 30 '22 12:09

Nick Johnson