I have an application which has rest end point and web end point.
I want to run both REST and WEB service locally using dev_appserver.py
I have tried the following
dev_appserver.py rest_app.yaml --port=5010 --admin_port=8000
dev_appserver.py web_app.yaml --port=5011 --admin_port=8001
I see the following error on one of my services (rest service)
`OperationalError: database is locked`
Do I have to do anything special to make sure both those services can read/write to a shared database without any conditions (or similar bad things !!)
My goal is to run multiple services (rest and web in this case) locally and those services should data. What is the best way to do this (using dev_appserver.py locally) and in GAE itself (this will come later when I push my application to GAE :D )
The reason for which you're getting
OperationalError: database is locked
is that the 2dev_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 viadev_appserver.py --help
):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 singledev_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 casemain/main.yaml
):And this is how the devserver automatically assigns the ports each service listens to, displayed when the server starts: