Created
February 15, 2020 18:29
-
-
Save dermesser/035fe3e519ffbfdc6333a8c85bd98ec6 to your computer and use it in GitHub Desktop.
FastCGI config in purely systemd: This works for services expecting a socket on stdin, like HG Web (see example)
This file contains hidden or 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
[Unit] | |
Wants=network.service nginx.service | |
[Install] | |
Alias=hgweb | |
WantedBy=multi-user.target | |
[Service] | |
User=lbo | |
Type=exec | |
ExecStart=/home/lbo/hg/.config/hgweb.fcgi | |
StandardInput=socket | |
ExecStop=/usr/bin/kill $MAINPID | |
Restart=always |
This file contains hidden or 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
[Unit] | |
Description = FCGI socket for hgweb | |
[Socket] | |
ListenStream = /run/web/hgweb.socket | |
Accept = false | |
[Install] | |
WantedBy = sockets.target hgweb.service |
This file contains hidden or 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
#!/usr/bin/env python2 | |
# | |
# An example FastCGI script for use with flup, edit as necessary | |
# Path to repo or hgweb config to serve (see 'hg help hgweb') | |
config = "/home/lbo/hg/.config/hgweb_config" | |
# Uncomment and adjust if Mercurial is not installed system-wide | |
# (consult "installed modules" path from 'hg debuginstall'): | |
#import sys; sys.path.insert(0, "/path/to/python/lib") | |
# Uncomment to send python tracebacks to the browser if an error occurs: | |
#import cgitb; cgitb.enable() | |
from mercurial import demandimport; demandimport.enable() | |
from mercurial.hgweb import hgweb | |
from flup.server.fcgi import WSGIServer | |
application = hgweb(config) | |
WSGIServer(application).run() |
This file contains hidden or 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
[...] | |
location /lbo/hg/ { | |
fastcgi_pass unix:/run/web/hgweb.socket; | |
include fastcgi_hg; | |
fastcgi_intercept_errors on; | |
limit_except GET HEAD { | |
deny all; | |
} | |
} | |
[...] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment