feat(api): listen on unix socket with gunicorn
This commit is contained in:
parent
ec45717ccf
commit
1cb03c35d2
|
@ -1,5 +1,6 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=LibreTime API Service
|
Description=LibreTime API Service
|
||||||
|
Requires=libretime-api.socket
|
||||||
PartOf=libretime.target
|
PartOf=libretime.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
@ -13,7 +14,7 @@ Environment=LIBRETIME_CONFIG_FILEPATH=@@CONFIG_FILEPATH@@
|
||||||
ExecStart=/usr/bin/gunicorn \
|
ExecStart=/usr/bin/gunicorn \
|
||||||
--workers 4 \
|
--workers 4 \
|
||||||
--log-file - \
|
--log-file - \
|
||||||
--bind 127.0.0.1:8081 \
|
--bind unix:/run/libretime-api.sock \
|
||||||
libretime_api.wsgi
|
libretime_api.wsgi
|
||||||
ExecReload=/bin/kill -s HUP $MAINPID
|
ExecReload=/bin/kill -s HUP $MAINPID
|
||||||
User=libretime
|
User=libretime
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
[Unit]
|
||||||
|
Description=LibreTime API Socket
|
||||||
|
PartOf=libretime-api.service
|
||||||
|
|
||||||
|
[Socket]
|
||||||
|
ListenStream=/run/libretime-api.sock
|
||||||
|
SocketUser=@@DEFAULT_WEB_USER@@
|
||||||
|
SocketMode=640
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=sockets.target
|
6
install
6
install
|
@ -274,8 +274,9 @@ install_service() {
|
||||||
|
|
||||||
template_file "$service_src" "$service_dest" \
|
template_file "$service_src" "$service_dest" \
|
||||||
sed \
|
sed \
|
||||||
-e "s|User=.*|User=${LIBRETIME_USER}|" \
|
-e "s|^User=.*|User=${LIBRETIME_USER}|" \
|
||||||
-e "s|Group=.*|Group=${LIBRETIME_USER}|" \
|
-e "s|^Group=.*|Group=${LIBRETIME_USER}|" \
|
||||||
|
-e "s|@@DEFAULT_WEB_USER@@|${DEFAULT_WEB_USER}|g" \
|
||||||
-e "s|@@CONFIG_DIR@@|${CONFIG_DIR}|g" \
|
-e "s|@@CONFIG_DIR@@|${CONFIG_DIR}|g" \
|
||||||
-e "s|@@CONFIG_FILEPATH@@|${CONFIG_FILEPATH}|g" \
|
-e "s|@@CONFIG_FILEPATH@@|${CONFIG_FILEPATH}|g" \
|
||||||
-e "s|@@LOG_DIR@@|${LOG_DIR}|g" \
|
-e "s|@@LOG_DIR@@|${LOG_DIR}|g" \
|
||||||
|
@ -555,6 +556,7 @@ install_packages $(list_packages "$SCRIPT_DIR/api")
|
||||||
install_python_app "$SCRIPT_DIR/api[prod]"
|
install_python_app "$SCRIPT_DIR/api[prod]"
|
||||||
|
|
||||||
install_service "libretime-api.service" "$SCRIPT_DIR/api/install/systemd/libretime-api.service"
|
install_service "libretime-api.service" "$SCRIPT_DIR/api/install/systemd/libretime-api.service"
|
||||||
|
install_service "libretime-api.socket" "$SCRIPT_DIR/api/install/systemd/libretime-api.socket"
|
||||||
|
|
||||||
# Install Playout
|
# Install Playout
|
||||||
########################################################################################
|
########################################################################################
|
||||||
|
|
|
@ -37,6 +37,6 @@ server {
|
||||||
location ~ ^/(api/v2|api-auth) {
|
location ~ ^/(api/v2|api-auth) {
|
||||||
include proxy_params;
|
include proxy_params;
|
||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
proxy_pass http://127.0.0.1:8081;
|
proxy_pass http://unix:/run/libretime-api.sock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue