Skip to content

Commit 4e77bba

Browse files
Add route for application restart
Allows for members of the rtp group to restart this application through the web, rather than restarting all of apache
1 parent d3d1fbe commit 4e77bba

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

conditional/blueprints/cache_management.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import os
2+
import signal
13
import structlog
24

35
from conditional.util.ldap import ldap_is_eval_director
6+
from conditional.util.ldap import ldap_is_rtp
47
from conditional.util.ldap import ldap_get_housing_points
58
from conditional.util.ldap import ldap_get_active_members
69
from conditional.util.ldap import ldap_get_intro_members
@@ -14,6 +17,17 @@
1417
logger = structlog.get_logger()
1518
cache_bp = Blueprint('cache_bp', __name__)
1619

20+
@cache_bp.route('/restart')
21+
def restart_app():
22+
user_name = request.headers.get('x-webauth-user')
23+
24+
if not ldap_is_rtp(user_name):
25+
return redirect("/dashboard")
26+
27+
logger.info('api', action='restart conditional')
28+
os.kill(os.getpid(), signal.SIGINT)
29+
return "application restarted", 200
30+
1731

1832
@cache_bp.route('/clearcache')
1933
def clear_cache():

conditional/util/ldap.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ def ldap_is_eboard(username):
201201
return _ldap_is_member_of_group(username, 'eboard')
202202

203203

204+
def ldap_is_rtp(username):
205+
return _ldap_is_member_of_group(username, 'rtp')
206+
207+
204208
def ldap_is_intromember(username):
205209
return _ldap_is_member_of_group(username, 'intromembers')
206210

0 commit comments

Comments
 (0)