Skip to content

Commit

Permalink
Add nginx and systemd templates (#8770)
Browse files Browse the repository at this point in the history
So they can be copied during installation instead of looking
them up in the documentation

Make default sidekiq configuration use weighted queues

Remove deprecated docs directory
  • Loading branch information
Gargron committed Sep 24, 2018
1 parent 9f6662f commit 6465972
Show file tree
Hide file tree
Showing 28 changed files with 161 additions and 27 deletions.
8 changes: 4 additions & 4 deletions config/sidekiq.yml
@@ -1,10 +1,10 @@
---
:concurrency: 5
:queues:
- default
- push
- mailers
- pull
- [default, 6]
- [push, 4]
- [mailers, 2]
- [pull]
:schedule:
subscriptions_scheduler:
cron: '<%= Random.rand(0..59) %> <%= Random.rand(4..6) %> * * *'
Expand Down
17 changes: 17 additions & 0 deletions dist/mastodon-sidekiq.service
@@ -0,0 +1,17 @@
[Unit]
Description=mastodon-sidekiq
After=network.target

[Service]
Type=simple
User=mastodon
WorkingDirectory=/home/mastodon/live
Environment="RAILS_ENV=production"
Environment="DB_POOL=25"
Environment="MALLOC_ARENA_MAX=2"
ExecStart=/home/mastodon/.rbenv/shims/bundle exec sidekiq -c 25
TimeoutSec=15
Restart=always

[Install]
WantedBy=multi-user.target
17 changes: 17 additions & 0 deletions dist/mastodon-streaming.service
@@ -0,0 +1,17 @@
[Unit]
Description=mastodon-streaming
After=network.target

[Service]
Type=simple
User=mastodon
WorkingDirectory=/home/mastodon/live
Environment="NODE_ENV=production"
Environment="PORT=4000"
Environment="STREAMING_CLUSTER_NUM=1"
ExecStart=/usr/bin/npm run start
TimeoutSec=15
Restart=always

[Install]
WantedBy=multi-user.target
17 changes: 17 additions & 0 deletions dist/mastodon-web.service
@@ -0,0 +1,17 @@
[Unit]
Description=mastodon-web
After=network.target

[Service]
Type=simple
User=mastodon
WorkingDirectory=/home/mastodon/live
Environment="RAILS_ENV=production"
Environment="PORT=3000"
ExecStart=/home/mastodon/.rbenv/shims/bundle exec puma -C config/puma.rb
ExecReload=/bin/kill -SIGUSR1 $MAINPID
TimeoutSec=15
Restart=always

[Install]
WantedBy=multi-user.target
106 changes: 106 additions & 0 deletions dist/nginx.conf
@@ -0,0 +1,106 @@
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=CACHE:10m inactive=7d max_size=1g;

server {
listen 80;
listen [::]:80;
server_name example.com;
root /home/mastodon/live/public;
location /.well-known/acme-challenge/ { allow all; }
location / { return 301 https://$host$request_uri; }
}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;

ssl_protocols TLSv1.2;
ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;

# Uncomment these lines once you acquire a certificate:
# ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

keepalive_timeout 70;
sendfile on;
client_max_body_size 80m;

root /home/mastodon/live/public;

gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

add_header Strict-Transport-Security "max-age=31536000";

location / {
try_files $uri @proxy;
}

location ~ ^/(emoji|packs|system/accounts/avatars|system/media_attachments/files) {
add_header Cache-Control "public, max-age=31536000, immutable";
add_header Strict-Transport-Security "max-age=31536000";
try_files $uri @proxy;
}

location /sw.js {
add_header Cache-Control "public, max-age=0";
add_header Strict-Transport-Security "max-age=31536000";
try_files $uri @proxy;
}

location @proxy {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Proxy "";
proxy_pass_header Server;

proxy_pass http://127.0.0.1:3000;
proxy_buffering on;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;

proxy_cache CACHE;
proxy_cache_valid 200 7d;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
add_header X-Cached $upstream_cache_status;
add_header Strict-Transport-Security "max-age=31536000";

tcp_nodelay on;
}

location /api/v1/streaming {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Proxy "";

proxy_pass http://127.0.0.1:4000;
proxy_buffering off;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;

tcp_nodelay on;
}

error_page 500 501 502 503 504 /500.html;
}
1 change: 0 additions & 1 deletion docs/Contributing-to-Mastodon/Sponsors.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Contributing-to-Mastodon/Translating.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Extensions.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/README.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Running-Mastodon/Administration-guide.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Running-Mastodon/Development-guide.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Running-Mastodon/Heroku-guide.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Running-Mastodon/Production-guide.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Running-Mastodon/Scalingo-guide.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Running-Mastodon/Tuning.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Running-Mastodon/Vagrant-guide.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Specs-and-RFCs-used.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Using-Mastodon/2FA.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Using-Mastodon/Apps.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Using-Mastodon/FAQ.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Using-Mastodon/List-of-Mastodon-instances.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Using-Mastodon/User-guide.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Using-the-API/API.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Using-the-API/OAuth-details.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Using-the-API/Push-notifications.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Using-the-API/Streaming-API.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Using-the-API/Testing-with-cURL.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/Using-the-API/Tips-for-app-developers.md

This file was deleted.

0 comments on commit 6465972

Please sign in to comment.