-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstudio-server
More file actions
executable file
·52 lines (46 loc) · 1.36 KB
/
Copy pathstudio-server
File metadata and controls
executable file
·52 lines (46 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
STUDIO_TAG=${STUDIO_TAG:="studio-server"}
STUDIO_IP=${STUDIO_IP:="127.0.0.1"}
STUDIO_PORT=${STUDIO_PORT:="9999"}
STUDIO_DEBUG=${STUDIO_DEBUG:=""}
STUDIO_MODE=${STUDIO_MODE:="daemon"}
STUDIO_DATA=${STUDIO_DATA:="${0%/*}/data"}
PIDFILE="$STUDIO_DATA/.$TAG.pid"
PID=${PID:=""}
if [ -s "$PIDFILE" ]; then PID=$(cat "$PIDFILE"); fi
[ ! -z "$PID" ] && kill "$PID"
LOG_DIR="$STUDIO_DATA/log"
mkdir -p "$LOG_DIR"
PHP="php -S $STUDIO_IP:$STUDIO_PORT \
-q \
-d memory_limit=16M \
-d display_errors=Off \
-d error_reporting=E_ALL \
-d date.timezone=UTC \
-d cli_server.color=1 \
"
PHP_CLI_SERVER_WORKERS=4
if [ "$STUDIO_DEBUG" != "" ]; then
XDEBUG_SESSION=1
PHP_CLI_SERVER_WORKERS=1
PHP="$PHP \
-d xdebug.mode=profile \
-d xdebug.start_with_request=yes \
-d xdebug.use_compression=false \
"
fi
if [ "$STUDIO_INIT" != "" ]; then
studio :build $STUDIO_INIT
fi
APP="${0%/*}/app.php"
if [ "$STUDIO_CONFIG" != "" ]; then
REAL_APP=`realpath "${0%/*}/app.php"`
APP="$STUDIO_DATA/$STUDIO_TAG.php"
echo "<?php \$_SERVER += ['STUDIO_CONFIG'=>'$STUDIO_CONFIG','STUDIO_TAG'=>'$STUDIO_TAG','STUDIO_ENV'=>'$STUDIO_ENV','STUDIO_DATA'=>'$STUDIO_DATA']; require '$REAL_APP';" > "$APP"
fi
if [ "$STUDIO_MODE" = "daemon" ]; then
$PHP "$APP" -s $TAG >> "$LOG_DIR/app.log" 2>&1 &
echo $! > "$PIDFILE"
else
exec $PHP "$APP" -s $STUDIO_TAG
fi