1

Trying to run my app using the dispatch file like so:

  $ dev_appserver.py dispatch.yaml app1/app.yaml app2/app.yaml

gives me the following error:

Traceback (most recent call last):
  File "/Users/usera/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 101, in <module>
    _run_file(__file__, globals())
  File "/Users/usera/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 97, in _run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/Users/usera/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 1041, in <module>
    main()
  File "/Users/usera/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 1037, in main
    dev_server.stop()
  File "/Users/usera/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 845, in stop
    metrics.GetMetricsLogger().Stop()
  File "/Users/usera/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/metrics.py", line 117, in Stop
    total_run_time = int((Now() - self._start_time).total_seconds())
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'NoneType'

I'm using the latest gcloud installation from here. Each service/module (e.g. app1/app2 in the command above) is written in go.

Content of my dispatch file:

application: my-app

– url: “*/app2/*”
module: app2

– url: “*/app1/*”
module: app1

My python version is 2.7 of course. Any ideas?

orcaman
  • 6,263
  • 8
  • 54
  • 69
  • `self._start_time` is NOne – Avinash Raj Mar 01 '17 at 18:44
  • Possible duplicate of [Using gcloud console for Google App Engine causes a Runtime error from metrics](http://stackoverflow.com/questions/42495197/using-gcloud-console-for-google-app-engine-causes-a-runtime-error-from-metrics) – mgiuffrida Mar 10 '17 at 07:06

1 Answers1

1

I just ran into this problem too, and I believe the issue is dev_appserver requires a default module to route requests which don't match any dispatch rules.

I was able to define a default module by removing the service attribute from the app.yaml for my default module, and removing the dispatch rule for that module.

In your case, remove the service attribute from app1/app.yaml (if present), and remove the dispatch rule which points to app1 in dispatch.yaml.

Hope this helps!

  • Unless the app already has a `default` module as well, in which case that module's `.yaml` file needs to be added to the `dev_appserver.py` cmdline (I'd place it the 1st one after the dispatch file). – Dan Cornilescu Mar 18 '17 at 00:42
  • @DanCornilescu How do you define a "default" module? I don't see a property for that in [app.yaml](https://cloud.google.com/appengine/docs/standard/go/config/appref) – Geoffrey Arnold Mar 18 '17 at 01:18
  • By leaving its name undefined (as you mentioned in your answer) or by explicitly naming it as such: `service: default` or `module: default` – Dan Cornilescu Mar 18 '17 at 01:27
  • The `default` module is always required, not only for the `dispatch.yaml` file. See http://stackoverflow.com/questions/42360790/why-do-i-need-to-deploy-a-default-app-before-i-can-deploy-multiple-services-in – Dan Cornilescu Mar 18 '17 at 01:32
  • Thanks. In my case I have a default module setup and no service attribute in none of my apps – orcaman Mar 18 '17 at 15:15
  • Awesome, thanks @DanCornilescu. @orcaman, to solve your issue, add the `service: app2` attribute to `app2/app.yaml` and remove the dispatch rule for `app1` in your `dispatch.yaml`. That should do the trick! – Geoffrey Arnold Mar 18 '17 at 15:36