Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watchdog #95

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: python
python:
- "3.6"
- "3.7"
- "3.8"
os:
- linux
# - osx
Expand All @@ -26,9 +27,11 @@ install:
- conda install pytest flake8
# Install WPS
- python setup.py install
# Init DB
- pywps -c pywps.cfg migrate
before_script:
# Start WPS service on port 5000 on 0.0.0.0
- emu start --daemon --bind-host 0.0.0.0 --port 5000
- pywps -c pywps.cfg start --bind-host 0.0.0.0 &
- sleep 2
script:
- pytest -v -m 'not online' tests/
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ RUN conda env create -n wps -f environment.yml
# Install WPS
RUN ["/bin/bash", "-c", "source activate wps && python setup.py develop"]

# Init DB
RUN ["/bin/bash", "-c", "source activate wps && pywps -c /opt/wps/pywps.cfg migrate"]
cehbrecht marked this conversation as resolved.
Show resolved Hide resolved

# Start WPS service on port 5000 on 0.0.0.0
EXPOSE 5000
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["source activate wps && exec emu start -b 0.0.0.0 -c /opt/wps/etc/demo.cfg"]
CMD ["source activate wps && exec pywps -c /opt/wps/pywps.cfg start -b 0.0.0.0"]

# docker build -t birdhouse/emu .
# docker run -p 5000:5000 birdhouse/emu
Expand Down
29 changes: 9 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Configuration
APP_ROOT := $(abspath $(lastword $(MAKEFILE_LIST))/..)
APP_NAME := emu
CFG_FILE ?= pywps.cfg

# Bumpversion 'dry' config
# if 'dry' is specified as target, any bumpversion call using 'BUMP_XARGS' will not apply changes
Expand All @@ -25,10 +25,8 @@ help:
@echo " help to print this help message. (Default)"
@echo " install to install app by running 'pip install -e .'"
@echo " develop to install with additional development requirements."
@echo " start to start $(APP_NAME) service as daemon (background process)."
@echo " stop to stop $(APP_NAME) service."
tlvu marked this conversation as resolved.
Show resolved Hide resolved
@echo " restart to restart $(APP_NAME) service."
@echo " status to show status of $(APP_NAME) service."
@echo " migrate to upgrade or initialize database."
@echo " start to start pywps service."
@echo " clean to remove all files generated by build and tests."
@echo "\nTesting targets:"
@echo " test to run tests (but skip long running tests)."
Expand Down Expand Up @@ -62,24 +60,15 @@ develop:
@echo "Installing development requirements for tests and docs ..."
@-bash -c 'pip install -e ".[dev]"'

.PHONY: migrate
migrate:
@echo "Upgrade or initialize database ..."
@-bash -c 'pywps -c "$(CFG_FILE)" migrate'

.PHONY: start
start:
@echo "Starting application ..."
@-bash -c "$(APP_NAME) start -d"

.PHONY: stop
stop:
@echo "Stopping application ..."
@-bash -c "$(APP_NAME) stop"

.PHONY: restart
restart: stop start
@echo "Restarting application ..."

.PHONY: status
status:
@echo "Show status ..."
@-bash -c "$(APP_NAME) status"
@-bash -c 'pywps -c "$(CFG_FILE)" start'

.PHONY: clean
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
Expand Down
24 changes: 6 additions & 18 deletions docs/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,22 @@
Configuration
=============

Command-line options
--------------------

You can overwrite the default `PyWPS`_ configuration by using command-line options.
See the Emu help which options are available::

$ emu start --help
--hostname HOSTNAME hostname in PyWPS configuration.
--port PORT port in PyWPS configuration.

Start service with different hostname and port::

$ emu start --hostname localhost --port 5001

Use a custom configuration file
-------------------------------

You can overwrite the default `PyWPS`_ configuration by providing your own
PyWPS configuration file (just modifiy the options you want to change).
Use one of the existing ``sample-*.cfg`` files as example and copy them to ``etc/custom.cfg``.
PyWPS configuration file.
Use the existing ``pywps.cfg`` file as example and copy it to ``custom.cfg``.

For example change the hostname (*demo.org*) and logging level:

.. code-block:: sh

$ cd emu
$ vim etc/custom.cfg
$ cat etc/custom.cfg
$ cp pywps.cfg custom.cfg
$ vim custom.cfg
$ cat custom.cfg
[server]
url = http://demo.org:5000/wps
outputurl = http://demo.org:5000/outputs
Expand All @@ -43,7 +31,7 @@ Start the service with your custom configuration:
.. code-block:: sh

# start the service with this configuration
$ emu start -c etc/custom.cfg
$ pywps -c custom.cfg start


.. _PyWPS: http://pywps.org/
37 changes: 16 additions & 21 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Install the ``emu`` Conda package:
$ conda install -c birdhouse -c conda-forge emu
$ emu --help


Install from GitHub
-------------------

Expand Down Expand Up @@ -63,51 +62,47 @@ For development you can use this command:
OR
$ make develop

Start Emu PyWPS service
-----------------------
Initialize Database
-------------------

After successful installation you can start the service using the ``emu`` command-line.
Before you can start the service you need to initialize or upgrade the database:

.. code-block:: console

$ emu start --help # show help
$ emu start # start service with default configuration

OR
$ make migrate

$ emu start --daemon # start service as daemon
loading configuration
forked process id: 42
Start PyWPS service
-------------------

The deployed WPS service is by default available on:
After successful installation you can start the service using the ``pywps`` command-line.

http://localhost:5000/wps?service=WPS&version=1.0.0&request=GetCapabilities.
.. code-block:: console

.. NOTE:: Remember the process ID (PID) so you can stop the service with ``kill PID``.
# show help
$ pywps -h

You can find which process uses a given port using the following command (here for port 5000):
# start service with default configuration (pywps.cfg)
$ pywps -c pywps.cfg start

.. code-block:: console
The deployed WPS service is by default available on:

$ netstat -nlp | grep :5000
http://localhost:5000/wps?service=WPS&version=1.0.0&request=GetCapabilities.

Check the log files for errors:

.. code-block:: console

$ tail -f pywps.log
$ tail -f pywps.log

... or do it the lazy way
+++++++++++++++++++++++++

You can also use the ``Makefile`` to start and stop the service:
You can also use the ``Makefile`` to start and the service:

.. code-block:: console

$ make start
$ make status
$ tail -f pywps.log
$ make stop

Run Emu as Docker container
---------------------------
Expand Down
8 changes: 4 additions & 4 deletions docs/source/tutorial/using_postgres.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ for this database is::
# postgresql+psycopg2://user:password@host:port/dbname
postgresql+psycopg2://postgres:postgres@localhost:5432/postgres

Configure this connection string in ``etc/custom.cfg``, ``logging`` section, ``database`` option:
Configure this connection string in ``custom.cfg``, ``logging`` section, ``database`` option:

.. code-block:: console

$ vim etc/custom.cfg
$ vim custom.cfg
[logging]
level = INFO
database = postgresql+psycopg2://postgres:postgres@localhost:5432/postgres

Start the emu service:
Start the PyWPS service:

.. code-block:: console

$ emu start -c etc/custom.cfg
$ pywps -c custom.cfg start

Your Emu WPS service should be available at the following URL:

Expand Down
4 changes: 3 additions & 1 deletion emu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

from .__version__ import __author__, __email__, __version__

from .wsgi import application
from pywps.application import make_app

application = make_app()
Loading