Skip to content

Commit 887bbad

Browse files
committed
Tau - improve log handling
On macOS and Linux close stdout, stderr and stdin which have been inherited by the calling process (likely Daemon) before opening our own pointing to the tau log path. This reduces chances from the tau kill switch from hanging on these platforms. We also need to move our config to the file runtime.exs for the shell variables to be available to configure the logger.
1 parent 483a0b4 commit 887bbad

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

app/server/beam/tau/boot-lin.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,21 @@
22
set -e # Quit script on error
33
SCRIPT_DIR="$(dirname "$0")"
44
cd ${SCRIPT_DIR}
5+
6+
# Close standard output file descriptor
7+
exec 1<&-
8+
# Close standard error file descriptor
9+
exec 2<&-
10+
11+
# Close standard in file descriptor
12+
exec <&-
13+
14+
# Open standard output file for read and write.
15+
exec 1>>"$9"
16+
17+
# Redirect standard error to standard output
18+
exec 2>&1
19+
520
echo "Booting Sonic Pi on Linux..."
6-
TAU_ENABLED=$1 TAU_INTERNAL=$2 TAU_MIDI_ENABLED=$3 TAU_LINK_ENABLED=$4 TAU_IN_PORT=$5 TAU_API_PORT=$6 TAU_SPIDER_PORT=$7 TAU_DAEMON_PORT=$8 _build/"${MIX_ENV:-prod}"/rel/tau/bin/tau start
21+
22+
TAU_ENABLED=$1 TAU_INTERNAL=$2 TAU_MIDI_ENABLED=$3 TAU_LINK_ENABLED=$4 TAU_IN_PORT=$5 TAU_API_PORT=$6 TAU_SPIDER_PORT=$7 TAU_DAEMON_PORT=$8 TAU_LOG_PATH=$9 _build/"${MIX_ENV:-prod}"/rel/tau/bin/tau start

app/server/beam/tau/boot-mac.sh

100644100755
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,21 @@
22
set -e # Quit script on error
33
SCRIPT_DIR="$(dirname "$0")"
44
cd ${SCRIPT_DIR}
5+
6+
# Close standard output file descriptor
7+
exec 1<&-
8+
# Close standard error file descriptor
9+
exec 2<&-
10+
11+
# Close standard in file descriptor
12+
exec <&-
13+
14+
# Open standard output file for read and write.
15+
exec 1>>"$9"
16+
17+
# Redirect standard error to standard output
18+
exec 2>&1
19+
520
echo "Booting Sonic Pi on macOS..."
6-
TAU_ENABLED=$1 TAU_INTERNAL=$2 TAU_MIDI_ENABLED=$3 TAU_LINK_ENABLED=$4 TAU_IN_PORT=$5 TAU_API_PORT=$6 TAU_SPIDER_PORT=$7 TAU_DAEMON_PORT=$8 _build/"${MIX_ENV:-prod}"/rel/tau/bin/tau start
21+
22+
TAU_ENABLED=$1 TAU_INTERNAL=$2 TAU_MIDI_ENABLED=$3 TAU_LINK_ENABLED=$4 TAU_IN_PORT=$5 TAU_API_PORT=$6 TAU_SPIDER_PORT=$7 TAU_DAEMON_PORT=$8 TAU_LOG_PATH=$9 _build/"${MIX_ENV:-prod}"/rel/tau/bin/tau start

app/server/beam/tau/boot-win.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ set TAU_LOG_PATH=%9%
1717

1818
IF NOT DEFINED MIX_ENV SET "MIX_ENV=prod"
1919

20-
_build\%MIX_ENV%\rel\tau\bin\tau start
20+
_build\%MIX_ENV%\rel\tau\bin\tau start > "%9%" 2>&1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Config
1+
import Config
22

33
config :tau,
44
handle_otp_reports: true,
@@ -8,5 +8,5 @@ config :logger,
88
backends: [{LoggerFileBackend, :error_log}]
99

1010
config :logger, :error_log,
11-
path: System.get_env("TAU_LOG_PATH"),
11+
path: System.fetch_env!("TAU_LOG_PATH"),
1212
level: :info

0 commit comments

Comments
 (0)