The reason for which you're getting OperationalError: database is locked
is that the 2 dev_appserver.py
instances will collide trying to access the same database local storage dir, which by default is determined based on the app's name - identical for 2 services of the same app.
One way to avoid such collision is to also specify the local storage directory, using dev_appserver.py
's --storage_path
optional argument (which you can see via dev_appserver.py --help
):
--storage_path PATH path to the data (datastore, blobstore, etc.)
associated with the application. (default: None)
However using 2 different storage paths may produce unexpected results - if your services reference what should be the same information in that storage they might see different values.
The proper way of using dev_appserver.py
with multiple services of the same app is to run all the services through a single dev_appserver.py
instance, which will allocate different ports to each service.
For example I have an app with 3 services and using a dispatch file. This is how I invoke the dev server, from the app dir which is the parent dir of 3 service dirs (the dispatch file must be the 1st one in the list of .yaml
file args and I always follow it with the default module's one, in my case main/main.yaml
):
/usr/bin/python2.7 /usr/local/google_appengine/dev_appserver.py --host 0.0.0.0 --log_level=debug dispatch.yaml main/main.yaml buildin/buildin.yaml apartci/apartci.yaml
And this is how the devserver automatically assigns the ports each service listens to, displayed when the server starts:
INFO 2016-11-18 14:20:53,329 api_server.py:205] Starting API server at: http://localhost:40310
INFO 2016-11-18 14:20:53,330 dispatcher.py:185] Starting dispatcher running at: http://0.0.0.0:8080
INFO 2016-11-18 14:20:53,345 dispatcher.py:197] Starting module "default" running at: http://0.0.0.0:8081
INFO 2016-11-18 14:20:53,353 dispatcher.py:197] Starting module "buildin" running at: http://0.0.0.0:8082
INFO 2016-11-18 14:20:53,361 dispatcher.py:197] Starting module "apartci" running at: http://0.0.0.0:8083
INFO 2016-11-18 14:20:53,362 admin_server.py:116] Starting admin server at: http://localhost:8000