I have an issue and I'd like to use the Interactive console you get on the local dev server (http://localhost:8080/_ah/admin) on the cloud server to make sure a query is working as I expect.
I read before you can enable it - but how is it done?
Nick's answer doesn't work anymore when using the "threadsafe" option. Instead, you have to use:
- url: /admin/.*
script: google.appengine.ext.admin.application
login: admin
Add the following to your app.yaml, before any .* handler:
- url: /admin/.*
script: $PYTHON_LIB/google/appengine/ext/admin
login: admin
Another option for your use-case is to enable remote_api, then use the remote_api_shell.py tool included with the SDK, allowing you to test things from a local Python shell.
Related
I currently have a small Google App Engine project written in PHP. On a traditional web server, I would simply invoke this particular code via command line (e.g., php whatever.php). I'd like to set this up with cron.yaml to just run every hour or so without invoking a HTTP request if possible. How would you go about doing this?
You can do this by adding a handler url that points to your script as follows:
In your app.yaml it would look like this:
handlers:
- url: /mycron
script: cron.php
login: admin
The login parameter will only allow execution of the endpoint by Google system accounts or something like that so you enpoint won't be publicly accessible.
More information in the below link
ref: https://cloud.google.com/appengine/docs/standard/php/config/cron#securing_urls_for_cron
In order to schedule tasks using the cron.yaml file, otherwise known as cron jobs, you can use the following structure inside the file:
cron:
- description: "running my PHP code"
url: /your-app-url
target: your-service
schedule: every 60 minutes
You can edit the different cron fields to your convenience by following this syntax.
Place the cron.yaml file on the same directory as your app.yaml file (your application's root directory) and, before deploying, test it by going to http://localhost:8080/cron. If it works, you can deploy the application with the cron job by running this command:
gcloud app deploy cron.yaml
You can find additional information about cron jobs, such as how to retry failing cron jobs and securing or deleting them by following this link.
I use node managed vm on google app engine. After I delete google compute instance at console.cloud.google.com , I see instance created automatically in "Operations". (This happens before, I used to delete instances at appengine.google.com which moved to "console" now.) How this happened? And How can I delete it?
When the instance can not be deleted it is because, either when creating an instance the protection against the deletion was checked or because after creating an instance we activated the protection from Gcloud with the following command:
$ gcloud compute instances update < INSTANCE_PATH> --deletion-protection
Sample of Instance path: projects/your-project-265315/zones/us-central1-a/instances/your-instance-v3
Solution:
Active Google Cloud Shell:
Precondition:
Request permission for the user to access the machine (regardless of the SSH connection to the instance) to avoid 403: Insufficient Permission.
$ gcloud auth login
If the deletion of the instance is protected, eliminate the protection.
$ gcloud compute instances update <INSTANCE_PATH> --no-deletion-protection
Then we delete the instance by selecting the zone correctly.
$ gcloud compute instances delete <instance-path>
GL
Preventing accidental vm deletion
Auth login
You have to delete deployed version for Flexible VM. Since it's only one version, you have to deploy another one, for standard vm.
Most simple solution would be to deploy an empty version, w/o any code, just one static file. To do that create following app.yaml:
module: default
runtime: python27
api_version: '1.0'
threadsafe: true
handlers:
- url: /
static_files: index.html
upload: index.html
resources:
cpu: 0.1
memory_gb: 0.5
disk_size_gb: 10
put an empty index.html in same dir. And deploy it using:
gcloud preview app deploy app.yaml
After this, you'll be able to route all traffic to this dummy version, and then delete previous version deployed for Flexible VM.
You need to delete the module from your app description. Otherwise App Engine will keep spinning new instances in accordance with the scale settings in your module description.
The CircleCI appengine documentation suggests using a password to do deployment. How can I use the oauth2 flow instead of using passwords? I don't want to share my Google password.
Do I generate a ~/.appcfg_oauth2_tokens_java file, from token data stored as environment variables in CircleCI? Is there a simpler way?
I solved the issue this way:
deployment:
appengine:
branch: master
commands:
- erb .appcfg_oauth2_tokens_java.json > ~/.appcfg_oauth2_tokens_java # requires ENV in circle ci
- mvn -DskipTests=true appengine:update # tests have already been run
.appcfg_oauth2_tokens_java.json:
{
"credentials": {
"ubuntu": {
"access_token": "<%= ENV["GOOGLE_ACCESS_TOKEN"] %>",
"expiration_time_millis": 1431552739090,
"refresh_token": "<%= ENV["GOOGLE_REFRESH_TOKEN"] %>"
}
}
}
Then in CircleCI, configure the ENV variables for the two tokens. I got the tokens by locally running mvn appengine:update and going through the oAuth2 dance. Note: You may have to remove your existing ~/.appcfg_oauth2_tokens_java file first.
Reading the AppEngine SDK docs, it sounds like that would be a good approach. There is not a built-in way to do that on CircleCI.
If you don't want to use any user-related credential, you can leverage service accounts, like mentioned in this blog post:
Continuous Deployment with Google App Engine and CircleCI
I solved it this way on the latest GAE SDK 1.9.34 for Java.
Assuming you have a Base64 encoded ENV Variable with your JSON key for a service account you've created on the GCloud project:
dependencies:
pre:
- echo $GOOGLE_CLIENT_SECRET | base64 --decode > ${HOME}/client-secret.json
And then in the deployment section:
- $HOME/appengine-java-sdk-$APP_ENGINE_VERSION/bin/appcfg.sh -A $GCLOUD_PROJECT -M $GCLOUD_MODULE -V $BUILD_VERSION --service_account_json_key_file=$HOME/client-secret.json update $WAR_FOLDER
The --service_account_json_key_file doesn't seem to appear as an option when you use appcfg.sh help but it is there, and does work.
Im having problems deploying my GAE. I've got two running already so I should have all the right lirbaries and whatnot. But obviously Im missing something.
I registered my applet with googe appengine developers.
i enter the app_id in the app.yaml of the project as application name.
in cmd, i go to google_appengine and run the "appcfg.py update" on the root directory of my project. "C:/Development/GAE/projectname"
type in email and pw,
and then i get this error msg
12:47 AM Application: processing#######; version: 1
12:47 AM Host: appengine.google.com
12:47 AM
Starting update of app: processing######, version: 1
12:47 AM Getting current resource limits.
Password for ############gmail.com: Invalid username or password.
2014-09-19 00:47:36,404 ERROR appcfg.py:2416 An error occurred processing file '': HTTP Error 401: Unauthorized. Aborting.
Error 401: --- begin server output ---
Must authenticate first.
--- end server output ---
Any ideas what Im missing? Ive triple-checked all these steps cause thats all i can think of.
My App.yaml contains this
application: processing######
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /statics
static_dir: statics
- url: /sketches
static_dir: sketches
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.2"
- name: jinja2
version: latest
Ive upgraded my GAE to the latest version too, still no change. I also tried uploading it to a different application, same problem.
Ive added 2 static folder I use for to run Processing embedded in my website.
PS my app runs fine locally and there's nothing that throws errors or doesnt compile. I think the fault lies somewehre else.
Cheers
Ok so as usual, more research eventually revealed the answer. And stackoverflow.
Guess I missed this first because it specified with php.Stack Overflow Question
Basically i wasnt doing anything wrong afterall, the permission problem was that it was being blocked by my google account.
I had to go to my Account Security permissions, and enable access from less-secure devices.
This must be a new, recent setting Google changed, becuase Ive already deployed 2 apps before.
To mention here for other people with the same problem:
First go through the steps I went through to make sure everything is set up correctly.
Then you should solving it the way I did.
Otherwise you can try setting it up so you can upload without password, this might avoid the problem if it lies somewehre else --oauth without pw
Finally I read that for some people the problem was in timezones. When the time on their computer was different to GAE or server I think that lead to miscommunication, so double-check that your time is set correctly and that it agrees with the time you see in the Launcher Log.
well for me the below 02 options worked
appcfg.py update . --oauth2 --noauth_local_webserver
The authentication flow was :
the command and options generated a url in stdout, which i copied and accessed from my browser, the browser generated a code, which I gave in my command line. I could see appcfg as one of the apps under connected apps and services of my google account.
It seems like an error with your user or password.
Are you sure you can access the project in the developer console, the email configured under permissions is the one which you are using to connect and the app id in yaml file is the same ID on the developers console? If so, the only thing I can imagine is a fail in your password.
Maybe a key pressed? Try typing it in a text processor.
A last idea, deploy the app via the launcher of the sdk. Add the existing app in the file menu (search the app.yaml file) and click deploy to see if there you can authenticate.
http://code.google.com/appengine/docs/python/tools/uploadingdata.html
Here it is explained how to download data from a gAE app,
First thing to do is setting up remote_api.
The bulk loader tool communicates with your application running on App Engine using remote_api, a request handler included with the App Engine runtime environment that allows remote applications with the proper credentials to access the datastore remotely. There are two ways to install remote_api: automatically using the builtins directive, or you manually using the url directive.
I enabled it using builtins directive:
i changed app.yaml accordingly
builtins:
- remote_api: on
Its given that this directive finds "include.yaml" file for the remote_api and maps the request handler to /_ah/remote_api. Only administrators of the application can access this URL.
but i never came across include.yaml
after that i tried downloading data using the the commands given there
appcfg.py download_data --application=<app-id> --url=http://<appname>.appspot.com/[remote_api_path] --filename=<data-filename>
i'm getting an error saying permission denied, i'm confused. i am also not able to use "create_bulkloader_config" command, getting the same error, I'm confused, Thanks
Are you using open ID / federated login for your app? The remote API does not work with open ID, but there is a workaround here:
http://blog.notdot.net/2010/06/Using-remote-api-with-OpenID-authentication
Replace
builtins:
- remote_api: on
With
- url: /remote_api
script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
login: admin
You Should run the commandline as an admin user. The permission denied error you are getting refers to the appcfg script not being able to access a local file.