-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5dacd71
commit 08152e7
Showing
10 changed files
with
239 additions
and
52 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
url.rewrite-once = ( | ||
"^(/static($|/.*))$" => "$1", | ||
"^(/api/.*)$" => "/main.fcgi$1", | ||
"^(/unit_api/.*)$" => "/main.fcgi$1", | ||
) | ||
alias.url += ( | ||
"/static/" => "/var/www/pioreactorui/static/" | ||
) | ||
server.error-handler-404 = "/index.html" | ||
|
||
|
||
fastcgi.server += (".fcgi" => | ||
(( | ||
"socket" => "/tmp/main-fcgi.sock", | ||
"bin-path" => "/var/www/pioreactorui/main.fcgi", | ||
"check-local" => "disable", | ||
"max-procs" => 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
$HTTP["url"] !~ "^(/unit_api|/main.fcgi/unit_api)" { | ||
url.access-deny = ( "" ) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
server.modules = ( | ||
"mod_indexfile", | ||
"mod_access", | ||
"mod_alias", | ||
"mod_redirect", | ||
"mod_staticfile", | ||
) | ||
|
||
server.document-root = "/var/www/pioreactorui" | ||
server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) | ||
server.errorlog = "/var/log/lighttpd/error.log" | ||
server.pid-file = "/run/lighttpd.pid" | ||
server.username = "www-data" | ||
server.groupname = "www-data" | ||
server.port = 80 | ||
|
||
# features | ||
#https://redmine.lighttpd.net/projects/lighttpd/wiki/Server_feature-flagsDetails | ||
server.feature-flags += ("server.h2proto" => "enable") | ||
server.feature-flags += ("server.h2c" => "enable") | ||
server.feature-flags += ("server.graceful-shutdown-timeout" => 5) | ||
#server.feature-flags += ("server.graceful-restart-bg" => "enable") | ||
|
||
# strict parsing and normalization of URL for consistency and security | ||
# https://redmine.lighttpd.net/projects/lighttpd/wiki/Server_http-parseoptsDetails | ||
# (might need to explicitly set "url-path-2f-decode" = "disable" | ||
# if a specific application is encoding URLs inside url-path) | ||
server.http-parseopts = ( | ||
"header-strict" => "enable",# default | ||
"host-strict" => "enable",# default | ||
"host-normalize" => "enable",# default | ||
"url-normalize-unreserved"=> "enable",# recommended highly | ||
"url-normalize-required" => "enable",# recommended | ||
"url-ctrls-reject" => "enable",# recommended | ||
"url-path-2f-decode" => "enable",# recommended highly (unless breaks app) | ||
#"url-path-2f-reject" => "enable", | ||
"url-path-dotseg-remove" => "enable",# recommended highly (unless breaks app) | ||
#"url-path-dotseg-reject" => "enable", | ||
#"url-query-20-plus" => "enable",# consistency in query string | ||
) | ||
|
||
index-file.names = ( "index.php", "index.html" ) | ||
url.access-deny = ( "~", ".inc" ) | ||
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) | ||
|
||
# default listening port for IPv6 falls back to the IPv4 port | ||
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port | ||
include_shell "/usr/share/lighttpd/create-mime.conf.pl" | ||
include "/etc/lighttpd/conf-enabled/*.conf" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
set -e | ||
|
||
export LC_ALL=C | ||
|
||
DIR=/tmp/pioreactorui_cache | ||
|
||
mkdir -p $DIR | ||
|
||
touch $DIR/cache.db | ||
touch $DIR/cache.db-shm | ||
touch $DIR/cache.db-wal | ||
|
||
touch $DIR/huey.db | ||
touch $DIR/huey.db-shm | ||
touch $DIR/huey.db-wal | ||
|
||
chmod -R 770 $DIR/ | ||
chown -R pioreactor:www-data $DIR/ | ||
chmod g+s $DIR |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
set -x | ||
set -e | ||
|
||
export LC_ALL=C | ||
|
||
SRC_TAR=$1 | ||
TEMP_DIR=$(mktemp -d -t "pioreactorui_XXXX") | ||
UI_FOLDER=/var/www/pioreactorui | ||
|
||
function finish { | ||
# cleanup | ||
rm -rf "$TEMP_DIR" || true | ||
sudo systemctl restart lighttpd.service | ||
sudo systemctl restart huey.service | ||
} | ||
trap finish EXIT | ||
|
||
|
||
# unpack source provided | ||
tar -xzf "$SRC_TAR" -C $TEMP_DIR | ||
WORK_DIR=$(find "$TEMP_DIR" -mindepth 1 -maxdepth 1 -type d) # get the directory inside the archive, name is not predictable. | ||
|
||
echo $WORK_DIR | ||
# Verify that WORK_DIR is valid | ||
if [[ -z "$WORK_DIR" ]]; then | ||
echo "Failed to find the working directory inside TEMP_DIR" | ||
exit 1 | ||
fi | ||
|
||
# copy data over | ||
# use rsync because we want to merge custom yamls the user has, we any updates to our own yamls. | ||
rsync -ap --ignore-existing $UI_FOLDER/contrib/ $WORK_DIR/contrib/ 2>/dev/null || : | ||
|
||
if [ -f "$UI_FOLDER/.env" ]; then | ||
echo "Copying .env file" | ||
cp -p $UI_FOLDER/.env $WORK_DIR | ||
else | ||
echo ".env file does not exist in $UI_FOLDER" | ||
fi | ||
|
||
# swap folders | ||
rm -rf $UI_FOLDER | ||
mkdir $UI_FOLDER | ||
cp -rp $WORK_DIR/. $UI_FOLDER | ||
chgrp -R www-data $UI_FOLDER | ||
|
||
ENV=$UI_FOLDER/.env | ||
if [ -f "$ENV" ]; then | ||
echo "$ENV exists." | ||
else | ||
mv $UI_FOLDER/.env.example $ENV | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=Prepare cache for UI | ||
After=network.target firstboot.service | ||
Before=lighttpd.service huey.service | ||
|
||
[Service] | ||
User=pioreactor | ||
ExecStart=/bin/bash /usr/local/bin/create_diskcache.sh | ||
ExecStartPost=pio log -m "%n successful" -n systemd --local-only | ||
Type=oneshot | ||
StandardOutput=null | ||
StandardError=null | ||
|
||
[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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=Huey service for PioreactorUI | ||
After=network.target firstboot.service | ||
Before=lighttpd.service | ||
|
||
[Service] | ||
User=pioreactor | ||
WorkingDirectory=/var/www/pioreactorui | ||
ExecStart=huey_consumer tasks.huey -n -b 1.0 -w 2 -f -C | ||
ExecStartPost=pio log -m "%n successful" -n systemd --local-only | ||
StandardOutput=null | ||
StandardError=null | ||
|
||
[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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[Unit] | ||
Description=Lighttpd Daemon | ||
After=network-online.target | ||
|
||
[Service] | ||
Type=simple | ||
PIDFile=/run/lighttpd.pid | ||
ExecStartPre=/usr/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf | ||
ExecStart=/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf | ||
ExecReload=/bin/kill -USR1 $MAINPID | ||
Restart=on-failure | ||
|
||
[Install] | ||
WantedBy=multi-user.target |