-
-
Save alexandrule/a8b3de3e6ad79b2428c2cf5ebe7ef1d5 to your computer and use it in GitHub Desktop.
Example of a systemd service file to start a Sinatra app.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/systemd/system/foo.service | |
[Unit] | |
Description=Foo service | |
Wants=nginx.service | |
Requires=postgresql.service | |
After=postgresql.service | |
[Service] | |
Type=simple | |
User=foo | |
Group=foo | |
ExecStart=/srv/foo/app/serve | |
Restart=always | |
TimeoutSec=10 | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/sites-enabled/foo | |
# example nginx config, which proxies /foo to this app | |
server { | |
# ...basic stuff omitted... | |
location / { | |
try_files $uri $uri/ =404; | |
} | |
location /foo { | |
# this nginxroot directory has "foo" symlinked to /srv/foo/app/public | |
# to avoid having to rewrite that prefix out here :) | |
root /srv/foo/nginxroot; | |
try_files $uri @foosinatra; | |
} | |
location @foosinatra { | |
include /etc/nginx/sinatra_params; | |
proxy_pass http://localhost:1234; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cd $(dirname $(readlink -f "$0")) | |
rackup --env production -o 127.0.0.1 -p 1234 >>log/production.log 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/sinatra_params | |
# extra headers that seem to be needed for Sinatra apps, especially when nginx uses https | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header X-Forwarded-Host $host; | |
proxy_set_header Host $http_host; | |
proxy_set_header Connection ""; | |
proxy_http_version 1.1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment