fix sockets conf

This commit is contained in:
bakatrouble 2019-03-08 18:55:46 +03:00
parent 056b8a249d
commit 81fa46faed
2 changed files with 12 additions and 1 deletions

View File

@ -1,5 +1,7 @@
import os
import socket import socket
from os import environ from os import environ
from pathlib import Path
from sanic import Sanic from sanic import Sanic
from sanic.request import Request from sanic.request import Request
@ -55,6 +57,13 @@ if __name__ == '__main__':
if DEBUG: if DEBUG:
app.run(host='localhost', port=8080, debug=True, auto_reload=True) app.run(host='localhost', port=8080, debug=True, auto_reload=True)
else: else:
socket_address = Path('/tmp/drop.sock')
try:
socket_address.unlink()
except OSError:
if socket_address.exists():
raise
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.bind('/tmp/drop.sock') sock.bind(socket_address)
app.run(sock=sock, workers=2) app.run(sock=sock, workers=2)

View File

@ -3,6 +3,8 @@ Description=Web file share socket
PartOf=drop.service PartOf=drop.service
[Socket] [Socket]
User=arch
Group=arch
ListenStream=/tmp/drop.sock ListenStream=/tmp/drop.sock
[Install] [Install]