mirror of
https://gitlab.com/tildes/tildes.git
synced 2026-04-16 06:18:34 +02:00
Reload gunicorn from cronjob, delete gunicorn_reloader
Closes tildes-community/tildes-cf#3 See merge request tildes-community/tildes-cf!6
This commit is contained in:
@@ -35,10 +35,13 @@
|
||||
hour: 0
|
||||
minute: 10
|
||||
|
||||
# Also reloads gunicorn if CSS updated, to update the cache-busting strings
|
||||
- name: Add cronjob for generating site-icons CSS file
|
||||
cron:
|
||||
name: generate_site_icons_css
|
||||
job: "{{ bin_dir }}/python -c \"from scripts.generate_site_icons_css import generate_css; generate_css()\""
|
||||
job: >
|
||||
{{ bin_dir }}/python -c "from scripts.generate_site_icons_css import generate_css; generated = generate_css(); exit(0 if generated else 1)"
|
||||
&& sudo systemctl reload gunicorn.service
|
||||
user: "{{ app_username }}"
|
||||
minute: "*/5"
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
[Path]
|
||||
PathChanged=/opt/tildes/static/css/site-icons.css
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,10 +0,0 @@
|
||||
[Unit]
|
||||
Description=gunicorn reloader
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/systemctl reload gunicorn.service
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -29,35 +29,8 @@
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
# Set up the gunicorn_reloader service, which reloads gunicorn whenever certain files
|
||||
# are changed (such as static files, to update the cache-busting strings)
|
||||
- name: Create gunicorn_reloader service file
|
||||
copy:
|
||||
src: gunicorn_reloader.service
|
||||
dest: /etc/systemd/system/gunicorn_reloader.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
- name: Create gunicorn_reloader path-monitoring file
|
||||
copy:
|
||||
src: gunicorn_reloader.path
|
||||
dest: /etc/systemd/system/gunicorn_reloader.path
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
- name: Start and enable gunicorn_reloader path-monitoring service, with fallback
|
||||
block:
|
||||
- name: Start and enable gunicorn_reloader path-monitoring service
|
||||
systemd_service:
|
||||
name: gunicorn_reloader.path
|
||||
state: started
|
||||
enabled: true
|
||||
rescue:
|
||||
# Likely Docker; systemctl3.py doesn't support .path, so enable .service here
|
||||
- name: Start and enable gunicorn.service (if .path service fails)
|
||||
systemd_service:
|
||||
name: gunicorn.service
|
||||
state: started
|
||||
enabled: true
|
||||
- name: Start and enable gunicorn service
|
||||
systemd_service:
|
||||
name: gunicorn.service
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
@@ -34,10 +34,13 @@ def _is_output_file_outdated() -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def generate_css() -> None:
|
||||
"""Generate the CSS file for site icons and replace the old one."""
|
||||
def generate_css() -> bool:
|
||||
"""Generate the CSS file for site icons and replace the old one.
|
||||
|
||||
Return True if generated, otherwise return False if skipped.
|
||||
"""
|
||||
if not _is_output_file_outdated():
|
||||
return
|
||||
return False
|
||||
|
||||
with NamedTemporaryFile(mode="w") as temp_file:
|
||||
for filename in os.listdir(ICON_FOLDER):
|
||||
@@ -54,3 +57,5 @@ def generate_css() -> None:
|
||||
|
||||
# set file permissions to 644 (rw-r--r--)
|
||||
os.chmod(OUTPUT_FILE, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
|
||||
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user