module configuration

452 views
Skip to first unread message

bsr

unread,
Oct 24, 2013, 11:02:19 AM10/24/13
to google-ap...@googlegroups.com
I am modeling my app something similar to https://github.com/GoogleCloudPlatform/appengine-modules-helloworld-python

please find the attached program in go. I run it like,

dev_appserver.py dispatch.yaml mobile_frontend.yaml static_backend.yaml app.yaml

Qn: 
1. It gives error " multiple registrations for /_ah/start". How can I initialize each module, if only one allowed.
2. I hope GO allows similar config as python. But, when I tried locally, the url handlers specified in module (app) yaml are not registered.

say, if I have something like listed in 

handlers:
- url: /scripts/backend
  static_dir: backend/scripts

it is not served if provided with a url, '/scripts/backend/scripts/backend/test.js' 

can you help with the attached program to make it work like the python program, also show how to register (static) handlers in module yaml file.

thanks a lot,
bsr.





module.zip

Glenn Lewis

unread,
Oct 24, 2013, 11:35:21 AM10/24/13
to bsr, google-ap...@googlegroups.com

One problem might be that app.yaml always needs to be listed first and then all other modules afterward.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

bsr

unread,
Oct 24, 2013, 12:03:40 PM10/24/13
to google-ap...@googlegroups.com, bsr
Thanks Glenn. I tried, still getting the same error. I know in GO http you can only register one handler for a uri, else it panics. From the module doc, it say it sends startup request to '/_ah/start' for each module. So, not sure.

To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine-go+unsub...@googlegroups.com.

Glenn Lewis

unread,
Oct 24, 2013, 6:09:48 PM10/24/13
to bsr, google-ap...@googlegroups.com
Dave told me that devappserver uses all sources recursively under the dir containing the .yaml file, and he recommended moving the yaml files into their own source directories.

So for your example, I moved "app.yaml" into the "frontend" directory, and the other two to their corresponding directories, like this:

$ ls -R
.:
dispatch.yaml  frontend/  mobile_frontend/  static_backend/

./frontend:
app.yaml  frontend.go

./mobile_frontend:
m.go  mobile_frontend.yaml

./static_backend:
s.go  static_backend.yaml

Once I did that, I started it up like this (and tested it from another terminal window with 'curl'):
$ dev_appserver.py dispatch.yaml */*.yaml
INFO     2013-10-24 22:04:41,943 sdk_update_checker.py:245] Checking for updates to the SDK.
INFO     2013-10-24 22:04:42,012 sdk_update_checker.py:273] The SDK is up to date.
INFO     2013-10-24 22:04:42,026 api_server.py:143] Starting API server at: http://localhost:60392
INFO     2013-10-24 22:04:42,027 dispatcher.py:159] Starting dispatcher running at: http://localhost:8080
INFO     2013-10-24 22:04:42,077 dispatcher.py:171] Starting module "default" running at: http://localhost:8081
INFO     2013-10-24 22:04:42,125 dispatcher.py:171] Starting module "mobile-frontend" running at: http://localhost:8082
INFO     2013-10-24 22:04:42,172 dispatcher.py:171] Starting module "static-backend" running at: http://localhost:8083
INFO     2013-10-24 22:04:42,173 admin_server.py:117] Starting admin server at: http://localhost:8000
2013/10/24 22:04:45 INFO: frontend
INFO     2013-10-24 22:04:45,079 module.py:608] default: "GET / HTTP/1.1" 200 11
2013/10/24 22:04:46 INFO: frontend
INFO     2013-10-24 22:04:46,623 module.py:608] default: "GET / HTTP/1.1" 200 11
INFO     2013-10-24 22:04:47,692 module.py:608] mobile-frontend: "GET / HTTP/1.1" 404 19
INFO     2013-10-24 22:04:49,110 module.py:608] static-backend: "GET / HTTP/1.1" 404 19

I hope that helps.
-- Glenn



To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Glenn Lewis | Software Engineer | gml...@google.com | 949-274-8923

bsr

unread,
Oct 24, 2013, 10:06:42 PM10/24/13
to google-ap...@googlegroups.com, bsr
Glenn. Thank you so much. It works great. below you can see the complete log. I could register static handler as well. Also, the updated program attached for reference.

Side qn. Are you a member of GAE Go team. Glad to see more official to support us.

thanks again.
bsr.


dev_appserver.py dispatch.yaml */*.yaml
INFO     2013-10-25 01:58:39,992 sdk_update_checker.py:245] Checking for updates to the SDK.
INFO     2013-10-25 01:58:41,407 sdk_update_checker.py:273] The SDK is up to date.
INFO     2013-10-25 01:58:41,440 api_server.py:139] Starting API server at: http://localhost:49703
INFO     2013-10-25 01:58:41,442 dispatcher.py:159] Starting dispatcher running at: http://localhost:8080
INFO     2013-10-25 01:58:41,446 dispatcher.py:171] Starting module "default" running at: http://localhost:8081
INFO     2013-10-25 01:58:41,457 dispatcher.py:171] Starting module "mobile-frontend" running at: http://localhost:8082
INFO     2013-10-25 01:58:41,469 dispatcher.py:171] Starting module "static-backend" running at: http://localhost:8083
INFO     2013-10-25 01:58:41,480 admin_server.py:117] Starting admin server at: http://localhost:8000
2013/10/25 01:58:48 INFO: frontend
INFO     2013-10-25 01:58:48,971 module.py:608] default: "GET /test HTTP/1.1" 200 11
INFO     2013-10-25 01:58:55,939 module.py:608] static-backend: "GET /work/test HTTP/1.1" 404 19
INFO     2013-10-25 01:59:24,018 module.py:608] static-backend: "GET /work/work/test HTTP/1.1" 404 19
INFO     2013-10-25 01:59:38,666 module.py:608] mobile-frontend: "GET /mobile/test HTTP/1.1" 404 19
INFO     2013-10-25 02:00:06,587 module.py:608] mobile-frontend: "GET /mobile/static/style.css HTTP/1.1" 200 25
INFO     2013-10-25 02:00:20,337 module.py:608] static-backend: "GET /work/static/style.css HTTP/1.1" 200 23
INFO     2013-10-25 02:00:24,747 module.py:608] default: "GET /static/style.css HTTP/1.1" 200 18
2013/10/25 02:00:57 INFO: mobile_frontend module started.
INFO     2013-10-25 02:00:57,374 module.py:608] mobile-frontend: "GET /_ah/start HTTP/1.1" 200 18
2013/10/25 02:01:28 INFO: handleGet
INFO     2013-10-25 02:01:28,962 module.py:608] mobile-frontend: "GET /mobile/test HTTP/1.1" 200 18
2013/10/25 02:02:18 INFO: static_backend module started.
INFO     2013-10-25 02:02:18,570 module.py:608] static-backend: "GET /_ah/start HTTP/1.1" 200 17
2013/10/25 02:02:25 INFO: handleGet
INFO     2013-10-25 02:02:25,544 module.py:608] static-backend: "GET /work/test HTTP/1.1" 200 17
2013/10/25 02:02:28 INFO: frontend
INFO     2013-10-25 02:02:28,965 module.py:608] default: "GET /test HTTP/1.1" 200 11
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine-go+unsubscribe...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine-go+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
module 2.zip

Glenn Lewis

unread,
Oct 24, 2013, 10:17:48 PM10/24/13
to bsr, google-ap...@googlegroups.com

Excellent! Glad to hear it.

Yes, I am a new member of the Go on App Engine team... two of my favorite Google technologies, so I am very excited to be here.  :-)

-- Glenn

To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.

bsr

unread,
Oct 25, 2013, 5:04:49 PM10/25/13
to google-ap...@googlegroups.com, bsr
Hello,

Doc says, for "Manual scaling". "Instances are sent a start request automatically by App Engine in the form of an empty GET request to /_ah/start.

1. I found it is not happening, and had to manually send a request to get it initialized. Is this correct behavior?

2. What is the behavior if the instance is automatic?

3. Where is the best place to register http handlers, in automatic and manual, .. instances. I would assume it is the same place ( /_ah/start) so that we can change instance type without changing code. Then at least, in dev server, this handler is not called unless you call it manually.

thanks.

bsr.


Glenn Lewis | Software Engineer | gml...@google.com | 949-274-8923

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.

Glenn Lewis

unread,
Oct 28, 2013, 1:57:36 PM10/28/13
to bsr, google-ap...@googlegroups.com
Re: #1, I am unable to duplicate this problem.  In the examples I have run, the start handler is getting called.  Do you have a simple example that demonstrates the problem?

Re: #2, You can think of automatic scaling as "classic App Engine" (before Modules).  Typically you would not provide your own /_ah/{start|stop} handlers for automatically-scaled instances, but if you did, they will still be called upon a new instance firing up.

Re: #3, I have seen registration of http handlers both within "init()" functions and within the start handler.  I believe you can do either.

More experienced team members of course will correct me if I am wrong.

-- Glenn


To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

bsr

unread,
Oct 28, 2013, 2:38:47 PM10/28/13
to google-ap...@googlegroups.com, bsr
Glenn, Please see the console log (with my comments below). Program is attached.
I could also be wrong in the instance configuration, please have a look at it.

Thanks again.
bsr.

dev_appserver.py dispatch.yaml */*.yaml
INFO     2013-10-28 18:25:22,146 sdk_update_checker.py:245] Checking for updates to the SDK.
INFO     2013-10-28 18:25:22,879 sdk_update_checker.py:273] The SDK is up to date.
INFO     2013-10-28 18:25:22,969 api_server.py:139] Starting API server at: http://localhost:60963
INFO     2013-10-28 18:25:22,971 dispatcher.py:159] Starting dispatcher running at: http://localhost:8080
INFO     2013-10-28 18:25:22,977 dispatcher.py:171] Starting module "default" running at: http://localhost:8081
INFO     2013-10-28 18:25:22,987 dispatcher.py:171] Starting module "mobile-frontend" running at: http://localhost:8082
INFO     2013-10-28 18:25:23,010 dispatcher.py:171] Starting module "static-backend" running at: http://localhost:8083
INFO     2013-10-28 18:25:23,023 admin_server.py:117] Starting admin server at: http://localhost:8000

// Now, I am going to send a request to http://localhost:8080/work ; this is registered through module "static_backend"

INFO     2013-10-28 18:26:54,374 module.py:608] static-backend: "GET /work HTTP/1.1" 404 19

//but failed. Now, I manually send a req to _ah/start of the respective module

http://localhost:8083/_ah/start2013/10/28 18:28:16 INFO: static_backend module started.
INFO     2013-10-28 18:28:16,636 module.py:608] static-backend: "GET /_ah/start HTTP/1.1" 200 17

Now, try again the previous req (http://localhost:8080/work)

2013/10/28 18:28:57 INFO: handleGet
INFO     2013-10-28 18:28:57,882 module.py:608] static-backend: "GET /work HTTP/1.1" 200 17

It is handled now!

This module uses instance_class: B1 ; (I though I read somewhere manual scaling is not supported by some instance type, not sure)
module "mobile-frontend" uses instance_class: F2
If I try the same test

INFO     2013-10-28 18:34:37,092 module.py:608] mobile-frontend: "GET /mobile HTTP/1.1" 404 19


Now, send a req to 2013/10/28 18:35:20 INFO: mobile_frontend module started.
INFO     2013-10-28 18:35:20,654 module.py:608] mobile-frontend: "GET /_ah/start HTTP/1.1" 200 18

above, I sent a req to http://localhost:8082/_ah/start


2013/10/28 18:35:57 INFO: handleGet
INFO     2013-10-28 18:35:57,493 module.py:608] mobile-frontend: "GET /mobile HTTP/1.1" 200 18

It worked!..
module 3.zip

Glenn Lewis

unread,
Oct 28, 2013, 6:31:00 PM10/28/13
to bsr, google-ap...@googlegroups.com
I was able to duplicate your instructions identically.
So I tried pushing your example to App Engine to see how it behaved, and got this:

Error 400: --- begin server output ---
Instance class B1 is only allowed with the 'manual' or 'basic' scaling value.
--- end server output ---

So I changed the static-backend module from a B1 to an F1 class instance and tried again.

I updated the dispatch.yaml:
$ appcfg.py --oauth2 update_dispatch .

But then was completely unable to get the apps to respond to any URLs (with/without module names, etc.) so it looks like I was wrong about /_ah/{start|stop}.
Automatically-scaled instances do not use the /_ah/{start|stop} mechanism at all.

I then moved the initialization from the start handlers to init() functions, got rid of the start and stop handlers entirely, and tried again.
After this, /test, /work, and /mobile all worked as expected.

Therefore, you will probably want to design your modules and plan to always use either automatic scaling (initializing in 'init()') or always use manual or basic scaling (adding start/stop handlers) and structure your code accordingly.

I hope that helps.

-- Glenn

To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

bsr

unread,
Oct 28, 2013, 8:02:49 PM10/28/13
to google-ap...@googlegroups.com, bsr
Thanks Glenn,

by changing the configuration to use something like, i see it works as expected.

instance_class: B2
manual_scaling:
  instances: 2

thanks again for the help.
Reply all
Reply to author
Forward
0 new messages