feat(docs): add service files

This commit is contained in:
Sam 2023-03-15 15:31:13 +01:00
parent 15109819df
commit 1344099d14
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
6 changed files with 85 additions and 0 deletions

View file

@ -0,0 +1,19 @@
[Unit]
Description=pronouns.cc API
After=syslog.target
After=network.target
Requires=postgresql.service redis.service
[Service]
RestartSec=2s
Type=simple
User=pronouns
Group=pronouns
AmbientCapabilities=
WorkingDirectory=/home/pronouns/src
ExecStart=/home/pronouns/src/pronouns web
Restart=always
Environment=USER=pronouns HOME=/home/pronouns
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,19 @@
[Unit]
Description=Clean pronouns.cc database
After=syslog.target
After=network.target
Requires=postgresql.service redis.service
[Service]
RestartSec=2s
Type=oneshot
User=pronouns
Group=pronouns
AmbientCapabilities=
WorkingDirectory=/home/pronouns/src
ExecStart=/home/pronouns/src/pronouns database clean
Restart=no
Environment=USER=pronouns HOME=/home/pronouns
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,9 @@
[Unit]
Description=Clean pronouns.cc database daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target

View file

@ -0,0 +1,19 @@
[Unit]
Description=pronouns.cc data exporter service
After=syslog.target
After=network.target
Requires=postgresql.service redis.service
[Service]
RestartSec=2s
Type=simple
User=pronouns
Group=pronouns
AmbientCapabilities=
WorkingDirectory=/home/pronouns/src
ExecStart=/home/pronouns/src/pronouns exporter
Restart=always
Environment=USER=pronouns HOME=/home/pronouns
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,19 @@
[Unit]
Description=pronouns.cc frontend
After=syslog.target
After=network.target
Requires=pronouns-api.service
[Service]
RestartSec=2s
Type=simple
User=pronouns
Group=pronouns
AmbientCapabilities=
WorkingDirectory=/home/pronouns/src/frontend
ExecStart=node build/index.js
Restart=always
Environment=USER=pronouns HOME=/home/pronouns
[Install]
WantedBy=multi-user.target

75
config/pronounscc.nginx Normal file
View file

@ -0,0 +1,75 @@
server {
server_name example.tld;
listen 80;
listen [::]:80;
# For SSL domain validation
root /var/www/html;
location /.well-known/acme-challenge/ { allow all; }
location /.well-known/pki-validation/ { allow all; }
location / { return 301 https://$server_name$request_uri; }
}
# For media proxy
proxy_cache_path /tmp/pronouns-media-cache levels=1:2 keys_zone=pronouns_media_cache:10m max_size=1g
inactive=720m use_temp_path=off;
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.tld;
ssl_session_timeout 1d;
ssl_session_cache shared:ssl_session_cache:10m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
ssl_stapling on;
ssl_stapling_verify on;
# To use a Let's Encrypt certificate
ssl_trusted_certificate /etc/letsencrypt/live/example.tld/chain.pem;
ssl_certificate /etc/letsencrypt/live/example.tld/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.tld/privkey.pem;
# To use Debian/Ubuntu's self-signed certificate (For testing or before issuing a certificate)
#ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
#ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
client_max_body_size 8m;
location ~ ^/api {
rewrite ^/api(.*) $1 break;
proxy_pass http://127.0.0.1:8080;
}
location ~ ^/media {
proxy_cache pronouns_media_cache;
slice 1m;
proxy_cache_key $host$uri$is_args$args$slice_range;
proxy_set_header Range $slice_range;
proxy_cache_valid 200 206 301 304 1h;
proxy_cache_lock on;
proxy_ignore_client_abort on;
proxy_buffering on;
chunked_transfer_encoding on;
# Rewrite URL to remove /media/ and add bucket
rewrite ^/media/(.*) /pronouns/$1 break;
proxy_pass http://127.0.0.1:9000;
}
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_pass http://127.0.0.1:3000;
}
}