app.yaml not being recognized by my app

166 views
Skip to first unread message

David Manz

unread,
Jan 16, 2019, 9:13:49 AM1/16/19
to Google App Engine
I am developing a simple Go app engine app and trying to add some images to my app, but after 'go run .', when I go to http://localhost:8080/x.png, I get the script and not the image.

My app.yaml is as follows:

runtime: go111

handlers:
- url: /stylesheets
static_dir: stylesheets

- url: /(.*\.(gif|png|jpg))$
static_files: static/\1
upload: static/.*\.(gif|png|jpg)$

- url: /.*
script: auto


The handler for images is not being triggered. Even if I type random junk in the app.yaml, I don't see an error. So, it seems to me that my app.yaml is being completely ignored. Any ideas what I'm doing wrong?

David



George (Cloud Platform Support)

unread,
Jan 16, 2019, 1:51:56 PM1/16/19
to Google App Engine
Hello David, 

What is your app's directory structure? What directory were you in, when running go run? What happens if you run dev_appserver.py app.yaml in the directory where your app.yaml resides? Is it ignored as well? You may refer to the "Serving Static Content" documentation page

This discussion group is oriented more towards general opinions, trends, and issues of general nature touching the app engine. For coding and programming architecture, as well as setting up Go apps, you may be better served in dedicated forums such as stackoverflow, where experienced programmers are within reach and ready to help. 

David Manz

unread,
Jan 16, 2019, 10:54:34 PM1/16/19
to Google App Engine
Hi George,

Thanks for the help.

I did find the documentation on serving static content, but I think there's something more basic that I'm missing.  If I delete app.yaml from the directory entirely, then I don't see any errors--just the same behavior.

My directory looks like this:

src/myapp/app.yaml
src/myapp/myappscript.go
src/myapp/myapptemplate.html
src/myapp/static/x.png

and I'm doing 'go run .' in the Google Cloud SDK Shell from inside src/myapp/

>dev_appserver.py ./app.yaml

INFO     2019-01-15 20:06:17,151 devappserver2.py:120] Skipping SDK update check.
INFO     2019-01-15 20:06:17,960 api_server.py:274] Starting API server at: http://localhost:4291
INFO     2019-01-15 20:06:17,960 stub_util.py:357] Applying all pending transactions and saving the datastore
INFO     2019-01-15 20:06:17,960 stub_util.py:360] Saving search indexes
Traceback (most recent call last):
  File "C:\Users\David\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\dev_appserver.py", line 96, in <module>
    _run_file(__file__, globals())
  File "C:\Users\David\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\dev_appserver.py", line 90, in _run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "C:\Users\David\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 454, in <module>
    main()
  File "C:\Users\David\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 442, in main
    dev_server.start(options)
  File "C:\Users\David\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 202, in start
    options.api_host, apiserver.port, wsgi_request_info_)
  File "C:\Users\David\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\dispatcher.py", line 262, in start
    ssl_port)
  File "C:\Users\David\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\dispatcher.py", line 403, in _create_module
    ssl_port=ssl_port)
  File "C:\Users\David\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\module.py", line 1299, in __init__
    super(AutoScalingModule, self).__init__(**kwargs)
  File "C:\Users\David\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\module.py", line 583, in __init__
    self._module_configuration)
  File "C:\Users\David\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\module.py", line 223, in _create_instance_factory
    sorted(repr(k) for k in runtime_factories.FACTORIES))))
RuntimeError: Unknown runtime 'go111'; supported runtimes are 'custom', 'go', 'java', 'java7', 'java8', 'php55', 'php72', 'python', 'python-compat', 'python27'.

David Manz

unread,
Jan 16, 2019, 11:31:50 PM1/16/19
to Google App Engine
If I modify the app.yaml like this:

#runtime: go111
runtime: go
api_version: go1

then I can run "dev_appserver.py ./app.yaml", and I can see my static content.

I don't know why runtime:go111 doesn't work, but I suppose this works for now.

Thanks again!

David

Omair (Cloud Platform Support)

unread,
Jan 17, 2019, 10:02:41 AM1/17/19
to Google App Engine
Hi David,

The reason it does not work for runtime go111 is because 'api_version' is not a supported element for Go 1.11. For full list of supported elements for Go 1.11 click here. The supported elements for Go 1.9 can be seen here.

I hope this helps. 

David Manz

unread,
Jan 17, 2019, 11:33:07 AM1/17/19
to Google App Engine
I didn't have 'api_version' in the app.yaml.  I don't think the app.yaml was being read at all.

With Go 1.11, what is the correct way to start the app locally?  Is it 'go run .', or is it 'goapp serve'?  'goapp serve' isn't working for me on Windows, because I have a space in my path:

> "\Users\David\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\goapp" serve
python: can't open file 'C:\Users\David\AppData\Local\Google\Cloud': [Errno 2] No such file or directory

David

Nicolas (Google Cloud Platform Support)

unread,
Jan 23, 2019, 3:30:13 PM1/23/19
to Google App Engine

Hi David,


Dev app server was previously used to test your application on local environment replicating the App Engine First Generation’s behavior however as GO 1.11 is now running on the Second Generation there is no need to use Dev app server anymore.


The Second Generation of App Engine will run your code exactly how it would run on your local machine.


That being said, the command to run your Go 1.11 application on your local environment is “go run”. Please note that Go 1.11 is in Beta release meaning that this feature could change and is not subject to any SLA.
Reply all
Reply to author
Forward
0 new messages