Skip to content

Commit 8b5a6e2

Browse files
dsteinkopfclaude
andauthored
fix(service): exec python so supervise can restart it (#273)
* fix(service): exec python so supervise can restart it Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(service): make the log run script POSIX-sh safe as well Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * docs: correct the rationale for replacing BASH_SOURCE On Venus OS /bin/sh is bash, so the original line worked. The change is portability hardening for a script that declares #!/bin/sh, not a bug fix. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 9266cc7 commit 8b5a6e2

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

service/log/run

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/bin/sh
22
exec 2>&1
33
#Script Directory
4-
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
5-
SCRIPT_DIR=$(realpath $SCRIPT_DIR/../../)
6-
SERVICE_NAME=$(basename $SCRIPT_DIR)
4+
# BASH_SOURCE and &> are bash-only in a #!/bin/sh script; they work today only
5+
# because /bin/sh is bash on Venus OS.
6+
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
7+
SCRIPT_DIR=$(realpath "$SCRIPT_DIR/../../")
8+
SERVICE_NAME=$(basename "$SCRIPT_DIR")
79
# documentation on how to use multilog https://manpages.debian.org/stretch/daemontools/multilog.8.en.html
8-
exec multilog t s153600 n2 /var/log/${SERVICE_NAME}
10+
exec multilog t s153600 n2 "/var/log/${SERVICE_NAME}"

service/run

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
#!/bin/sh
22
#Script Directory
3-
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
3+
# BASH_SOURCE and &> are bash-only in a #!/bin/sh script; they work today only
4+
# because /bin/sh is bash on Venus OS.
5+
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
46
#Define the version filename
5-
CODE_VERSION_FILE=$(realpath $SCRIPT_DIR/../version.txt)
7+
CODE_VERSION_FILE=$(realpath "$SCRIPT_DIR/../version.txt")
68
exec 2>&1
79
#Check if the file exists
810
if [ -f "$CODE_VERSION_FILE" ]; then
911
#If the file exists, print its contents to stdout
1012
cat "$CODE_VERSION_FILE"
1113
fi
12-
python $(realpath $SCRIPT_DIR/../dbus_opendtu.py)
14+
# exec so supervise watches python itself: otherwise a restart orphans python,
15+
# it keeps the D-Bus names, and the new process dies with "Bus name already exists".
16+
exec python "$(realpath "$SCRIPT_DIR/../dbus_opendtu.py")"

0 commit comments

Comments
 (0)