Skip to content

Instantly share code, notes, and snippets.

@cdent
Last active February 4, 2019 16:20
Show Gist options
  • Save cdent/4ca9f0ce7fab4fe5097e29d08306cd8e to your computer and use it in GitHub Desktop.
Save cdent/4ca9f0ce7fab4fe5097e29d08306cd8e to your computer and use it in GitHub Desktop.
#!/bin/bash -e
# Either install from pip if no $1, or $1 is a path or URL
# to an installable placement (such as a local copy of the
# repo).
PLACEMENT_LOCATION=${1:-openstack-placement}
# Make the virtualenv
python -m virtualenv -p python3 placetest
# Install placement and uwsgi
placetest/bin/pip install $PLACEMENT_LOCATION uwsgi
# Set basic configuration
export OS_API__AUTH_STRATEGY=noauth2
# Note that using sqlite doesn't work well with concurrent
# requests. Use mysql or postgresql if that's important here.
export OS_PLACEMENT_DATABASE__CONNECTION=sqlite:///placetest/cats
# Sync the database to have the right tables because we don't
# have https://review.openstack.org/#/c/619050/ yet
placetest/bin/placement-manage db sync
# run uwsgi in the background with moderate horsepower
placetest/bin/uwsgi -H placetest --http :8000 \
--wsgi-file placetest/bin/placement-api \
--daemonize placetest/placement-api.log \
--safe-pidfile placetest/uwsgi.pid \
--master --processes 2 --threads 25
# retrive the version doc
curl -s http://localhost:8000/
echo
echo "placement at http://localhost:8000"
echo "log at placetest/placement-api.log"
echo "api-ref: https://developer.openstack.org/api-ref/placement/"
echo "running via uwsgi, stop with kill -INT $(cat placetest/uwsgi.pid)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment