Commit 2eee3c84 authored by Philippe Pepiot's avatar Philippe Pepiot Committed by Denis Laxalde
Browse files

Handle /oai requests in a dedicated instance

Separate /oai requests in a dedicated cubicweb instance, so when all
threads on /oai are busy handling long OAI requests we can continue to
serve other requests.
parent 88b11cd6
......@@ -7,6 +7,12 @@ saemref-formula
A saltstack formula handling installation of `saem_ref`_.
The formula will run two web application server, one dedicated to OAIPMH
request to serve ``/oai`` on port 8081 and one for other requests on port 8080.
To use them in a single port you may configure a reverse proxy, such as apache2
or nginx, on front of the instances.
Available states
================
......
......@@ -6,6 +6,8 @@ saemref:
user: saemref
base_url:
port: 8080
oai_port: 8081
oai_threads: 8
anonymous_user:
anonymous_password:
wsgi: true
......
......@@ -11,3 +11,16 @@ stdout_logfile=/home/{{ saemref.instance.user }}/{{ saemref.instance.name }}.log
environment=CW_MODE=user,HOME=/home/{{ saemref.instance.user }},CW_INSTANCE={{ saemref.instance.name }}
autorestart=true
startsecs=10
[program:saemref-oai]
{% if saemref.instance.wsgi -%}
command=/home/{{ saemref.instance.user }}/venv/bin/gunicorn 'cubicweb.pyramid:wsgi_application()' --threads {{ saemref.instance.oai_threads }} --workers 1 --bind 0.0.0.0:{{ saemref.instance.oai_port }}
{% else -%}
command=/home/{{ saemref.instance.user }}/venv/bin/cubicweb-ctl pyramid -D {{ saemref.instance.name }}
{% endif -%}
environment=CW_MODE=user,HOME=/home/{{ saemref.instance.user }},CW_INSTANCE={{ saemref.instance.name }},CW_CONNECTIONS_POOL_SIZE={{ saemref.instance.oai_threads }},CW_PORT={{ saemref.instance.oai_port }}
user={{ saemref.instance.user }}
redirect_stderr=true
stdout_logfile=/home/{{ saemref.instance.user }}/{{ saemref.instance.name }}-oai.log
autorestart=true
startsecs=10
......@@ -5,6 +5,8 @@ saemref:
user: saemref
# http port
port: 8080
oai_port: 8081
oai_threads: 8
# Anonymous user
anonymous_user: "john"
anonymous_password: "secret"
......
......@@ -86,6 +86,8 @@ def test_pillars(File, Salt, SystemInfo):
'base_url': base_url,
'pool_size': 8,
'port': 8080,
'oai_port': 8081,
'oai_threads': 8,
'sessions_secret': 'Polichinelle',
'test_mode': True,
'user': 'saemref',
......@@ -122,15 +124,16 @@ def test_saemref_running(Process, Service, Socket, Command, supervisor_service_n
assert supervisord.user == "root"
assert supervisord.group == "root"
cubicweb = Process.get(ppid=supervisord.pid)
assert cubicweb.comm == "gunicorn"
assert cubicweb.user == "saemref"
assert cubicweb.group == "saemref"
childs = Process.filter(ppid=supervisord.pid)
assert [(c.comm, c.user, c.group) for c in childs] == 2 * [("gunicorn", "saemref", "saemref")]
assert Socket("tcp://0.0.0.0:8080").is_listening
assert Socket("tcp://0.0.0.0:8081").is_listening
html = Command.check_output("curl http://localhost:8080")
assert "<title>accueil (Référentiel SAEM)</title>" in html
xml = Command.check_output("curl http://localhost:8081/oai")
assert xml.startswith("<?xml ")
def test_saemref_sync_source_cronjob(Command):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment