I am using github.com/golang/appengine and its associated "datastore". I was hoping this package would allow me to use Datastore in a normal Go website. Unfortunately, my
c := appengine.NewContext(rq)
keeps giving my a "NewContext passed an unknown http.Request" error. My app.yaml contains
application: sdklessdatastoremusic
version: 1
runtime: go
api_version: go1
handlers:
- url: /.*
script: _go_app
vm: true
manual_scaling:
instances: 1
What should that YAML be, or is the problem elsewhere?
The App Engine packages only apply for when you are running on App Engine itself, not elsewhere.
Related
I would like to host PrivateBin from a GCP App Engine, but I don't know how to configure the app.yaml file. If somebody has done this before, I would appreciate the help. :)
I have tried two options, but neither of them worked:
runtime: php55
api_version: 1
threadsafe: yes
handlers:
- url: /.*
script: index.php
&
runtime: php55
api_version: 1
handlers:
- url: /(.*.(ico$|jpg$|png$|gif$|htm$|html$|css$|js$|xml$))
static_files: \1
upload: (.*.(ico$|jpg$|png$|gif$|htm$|html$|css$|js$|xml$))
application_readable: true
- url: /(.+)
script: \1
- url: /
script: index.php
How do you intend to store your data?
https://github.com/PrivateBin/PrivateBin/blob/master/INSTALL.md#using-a-database-instead-of-flat-files
Looks like private bin uses the filesystem by default, which wont work on GAE Standard. You could do that in GAE flex, but the directory where you are reading and writing to would need to be a mounted Google Cloud Storage Bucket or something for the data to be persistent (as well as be available to multiple instances) https://cloud.google.com/storage/docs/gcs-fuse
The better route seems to be to configure privatebin to use a SQL db, which would be Google Cloud SQL:
https://cloud.google.com/sql/docs/
https://cloud.google.com/php/getting-started/using-cloud-sql-with-mysql
I'm struggling to setup URL handlers in the handlers section of my app.yaml file for my standard engine php application.
Following code makes both mydomain.com/abc.php and mydomain.com display the abc.php file in my dist folder:
handlers:
- url: /(abc\.php)
script: dist/abc.php
- url: /(.*)
script: dist/abc.php
However, I don't want a catch all handler, so I removed it so only 1 handler exists:
handlers:
- url: /(abc\.php)
script: dist/abc.php
Now when I go to mydomain.com/abc.php, I'm getting a 500 error:
How can I make a targeted URL work on GAE without using a handler for all URL's?
My app.yaml file contained resources:
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 1
disk_size_gb: 10
Since this isn't supported by the App Engine Standard environment, simply commenting out this code resolved the issue.
I want to create very standard setup for GAE (php runtime): 2 modules with specific URLs (routings):
module-api for REST API
module-oli for backend static process ..
regarding to doc (https://cloud.google.com/appengine/docs/php/modules/ and https://cloud.google.com/appengine/docs/php/modules/routing) I've created 3 .yaml config files:
dispatch.yaml
application: ABC
dispatch:
- url: "*/oli/*"
module: module-oli
- url: "*/"
module: module-api
app.yaml
application: ABC
version: v1
module: module-api
runtime: php55
api_version: 1
handlers:
- url: /.*
script: public/api.php
module-oli.yaml
application: ABC
version: v1
module: module-oli
runtime: php55
api_version: 1
manual_scaling:
instances: 1
handlers:
- url: /.*
script: public/oli.php
I also tried many changes in URL handling, but the error I always get is "Duplicate module: module-api".
Can you help me please? Thank you in advance ..
I have no idea why, but (on my computer) it does not work just from googleAppEngineLauncher.app (OSX 10.11.3, googleAppEngineLauncher version 1.9.32), but it works if I use command line tools:
dev_appserver.py app.yaml module-oli.yaml
and only if I do not use param --skip_sdk_update_check (does not matter value)
more about naming modules (and using default module or not) .. it all works even if I name default module with specific name (of course, it causes error when not all request are dispatched to the module).
more about dispatching to modules; it works (as it's documented here). of course, it does not work at local development environment, as every single module runs at a different port (than the dispatch does not work, and if there is a module with manual_scaling, the _ah/start can not be handled and as err500 it stops the start)
here are all setup files, and how to run it:
app.yaml
application: <APPLICATION-ID>
module: default
version: v1
runtime: php55
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: blablabla.php
module-oli.yaml
application: <APPLICATION-ID>
version: v1
module: module-oli
runtime: php55
api_version: 1
threadsafe: yes
instance_class: B1
manual_scaling:
instances: 1
handlers:
- url: /oli/.*
script: blebleble-oli.php
dispatch.yaml
dispatch:
- url: "*/oli/*"
module: module-oli
- url: "*/*"
module: default
to run on local development environment: dev_appserver.py app.yaml module-oli.yaml .. (no automatic routing, instances are running on different ports)
one everything is deployed to gcloud and dispatching is updated (appcfg.py -A wellfedcat-1221 update_dispatch .), it works like this:
APPLICATION-ID.appspot.com/* : served by default module ..
APPLICATION-ID.appspot.com/oli/* : served by module-oli ..
the dispatching is necessary when you want to use our own domain to map to gcloud ..
thank you #Tom for help!
I'm trying to setup Laravel 4 with google app engine.
Here's the step on how I setup
Download laravel using composer following the docs step.
Create a app.yaml file with this
application: laraveldemo
version: 1
runtime: php
api_version: 1
handlers:
- url: /favicon\.ico static_files: public/favicon.ico upload: public/favicon\.ico
- url: /.* script: public/index.php
and start engine.
And thats what I get, following this http://blog.neoxia.com/laravel-4-on-google-appengine-for-php/
Seriously, I don't know what's the problem, it works fine with MAMP.
This problem is related to the 'native' session driver. You can switch you driver to 'cookie' and your app will run just fine.
I am using App Engine Modules in my python project. (https://developers.google.com/appengine/docs/python/modules/#Python_Background_threads)
I am also receiving email in m project:
https://developers.google.com/appengine/docs/python/mail/receivingmail
I want to direct the emails to my worker module and not the default module. To that end my worker.yaml has the following settings
worker.yaml
api_version: 1
application: integrate
module: worker
version: 1-0-0
runtime: python27
threadsafe: true
inbound_services:
- mail
builtins:
- deferred: on
handlers:
- url: /admin/.+
script: src.worker.main.app
login: admin
- url: /_ah/mail/.+
script: src.worker.main.app
login: admin
- url: /.*
script: src.worker.main.app
app.yaml
api_version: 1
application: integrate
version: 1-0-0
runtime: python27
threadsafe: true
builtins:
- deferred: on
handlers:
- url: /admin/.+
script: src.default.main.app
login: admin
- url: /.*
script: src.default.main.app
I even tried adding a dispatch.yaml
application: integrate
dispatch:
- url: "*/_ah/mail/.+"
module: worker
But no matter what I do the emails which reach my app are handled by the default module. Any idea what I am missing here? I see the emails coming in but no matter what I do they only go to the default module.
Inbound services could be used only within default module and that is expected behavior. The fact that it works for you locally in devserver is a bug, actually.
Just some additional info for the answer which may help folks in a similar situation.
I noticed in the DevServer log:
"Skipping dispatch.yaml rules because /_ah/mail/[EMAIL_ADDRESS_FOR_APP] is not a dispatchable path."
This is no doubt due to local config, however.
Regardless, the workaround I have now using Tasks is:
Dispatch or directly handle Inbound Mail in the default module
Provide a script handler that creates a Task, taking the relevant MailMessage data as the payload
Set the TaskQueue in queue.yaml to target the module you wish to process the payload data, e.g. a 'worker' module