Skip to content

Commit acf8f3f

Browse files
Merge pull request #605 from geoadmin/develop
New Release v2.2.0 - #minor
2 parents b7f1425 + ebc60d1 commit acf8f3f

5 files changed

Lines changed: 37 additions & 2 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,9 @@ The service is configured by Environment Variable:
506506
| STAC_BROWSER_BASE_PATH | `browser/index.html` | STAC Browser base path. |
507507
| GUNICORN_WORKERS | `2` | Number of Gunicorn workers |
508508
| GUNICORN_WORKER_TMP_DIR | `None` | Path to a tmpfs directory for Gunicorn. If `None` let gunicorn decide which path to use. See https://docs.gunicorn.org/en/stable/settings.html#worker-tmp-dir. |
509-
| GUNICORN_STACK_DUMP_DELAY | `29` | Upon exit, how long to wait before logging stack traces. The default is one second less than `GUNICORN_GRACEFUL_TIMEOUT`. Setting this to a value equal or greater to `GUNICORN_GRACEFUL_TIMEOUT` effectively disables stack dumping.
510-
| GUNICORN_GRACEFUL_TIMEOUT | `30` | The [`graceful_timeout`](https://docs.gunicorn.org/en/stable/settings.html#graceful-timeout) setting passed to gunicorn.
509+
| GUNICORN_STACK_DUMP_DELAY | `29` | Upon exit, how long to wait before logging stack traces. The default is one second less than `GUNICORN_GRACEFUL_TIMEOUT`. Setting this to a value equal or greater to `GUNICORN_GRACEFUL_TIMEOUT` effectively disables stack dumping. |
510+
| GUNICORN_GRACEFUL_TIMEOUT | `30` | The [`graceful_timeout`](https://docs.gunicorn.org/en/stable/settings.html#graceful-timeout) setting passed to gunicorn. |
511+
| GUNICORN_KEEPALIVE | `2` | The [`keepalive`](https://docs.gunicorn.org/en/stable/settings.html#keepalive) setting passed to gunicorn. |
511512

512513
#### **Database settings**
513514

@@ -544,6 +545,7 @@ These settings are read from `settings_dev.py`
544545

545546
| Env | Default | Description |
546547
|-------------|-----------------------|----------------------------------------|
548+
| CHECKER_DELAY | `0` | Delay the response of the checker endpoint by that number of seconds. |
547549
| DEBUG | `False` | Set django DEBUG flag |
548550
| DEBUG_PROPAGATE_API_EXCEPTIONS | `False` | When `True` the API exception are treated as in production, using a JSON response. Otherwise in DEBUG mode the API exception returns an HTML response with backtrace. |
549551
| EXTERNAL_TEST_ASSET_URL | `"https://prod-[...].jpg"` | The URL of an externally hosted jpg file that's used in the external asset tests |

app/config/settings_prod.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,7 @@ def get_logging_config():
378378
SESSION_COOKIE_AGE = env('SESSION_COOKIE_AGE', int, default=60 * 60 * 24 * 7 * 2)
379379
SESSION_COOKIE_SAMESITE = env('SESSION_COOKIE_SAMESITE', str, default='Lax')
380380
SESSION_COOKIE_SECURE = env('SESSION_COOKIE_SECURE', bool, default=False)
381+
382+
# Delay to inject in the checker endpoint, in seconds. This is only meant to be
383+
# used for test purpose.
384+
CHECKER_DELAY = env('CHECKER_DELAY', int, default=0)

app/config/urls.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
1. Import the include() function: from django.urls import include, path
1414
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1515
"""
16+
import time
17+
1618
from django.conf import settings
1719
from django.contrib import admin
1820
from django.http import JsonResponse
@@ -23,6 +25,9 @@
2325

2426

2527
def checker(request):
28+
if settings.CHECKER_DELAY > 0:
29+
time.sleep(settings.CHECKER_DELAY)
30+
2631
data = {"success": True, "message": "OK"}
2732

2833
return JsonResponse(data)

app/tests/test_checker.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import time
2+
3+
from django.test import Client
4+
from django.test import TestCase
5+
from django.test import override_settings
6+
7+
8+
class CheckerTestCase(TestCase):
9+
10+
def setUp(self):
11+
self.client = Client()
12+
13+
def test_checker(self):
14+
response = self.client.get('/checker')
15+
self.assertEqual(response.status_code, 200)
16+
17+
@override_settings(CHECKER_DELAY=2)
18+
def test_checker_delayed(self):
19+
start = time.time()
20+
response = self.client.get('/checker')
21+
end = time.time()
22+
self.assertEqual(response.status_code, 200)
23+
self.assertGreater(end, start + 2, f'Expected at least 2s, only took {end - start}')

app/wsgi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def dump_stacks():
100100
'worker_tmp_dir': os.environ.get('GUNICORN_WORKER_TMP_DIR', None),
101101
'timeout': 60,
102102
'graceful_timeout': int(os.environ.get('GUNICORN_GRACEFUL_TIMEOUT', 30)),
103+
'keepalive': int(os.environ.get('GUNICORN_KEEPALIVE', 2)),
103104
'logconfig_dict': get_logging_config(),
104105
}
105106
StandaloneApplication(application, options).run()

0 commit comments

Comments
 (0)