Can't start Unity Accelerator v1.0.196+ge1f9988 on Linux

The service cannot be started because the conditions for determining the result of the kill command in the start function of the Linux version startup script are incorrect.
Below is the debug log of the script. Do not start the service even if the pid file does not exist.

~ # /bin/sh -x /opt/Unity/accelerator/unity-accelerator-launch start
+ '[' start '=' -fg ]
+ FOREGROUND=false
+ basename /opt/Unity/accelerator/unity-accelerator-launch .sh
+ BN=unity-accelerator-launch
+ AGENT=/opt/Unity/accelerator/unity-accelerator
+ PRODUCT_SLUG=unity-accelerator
+ STORAGEDIR=/root/.config/unity-accelerator
+ NPMPATH=
+ PIDFN=/root/.config/unity-accelerator/unity-accelerator.pid
+ LOGFN=/root/.config/unity-accelerator/unity-accelerator-launch-launch.log
+ start
+ '[' -n  ]
+ cat /root/.config/unity-accelerator/unity-accelerator.pid
+ pid=
+ kill -0
+ echo 'unity-accelerator is running as '
unity-accelerator is running as
+ exit 0

The service has been started with the following modifications.

~ # diff -u /opt/Unity/accelerator/unity-accelerator-launch.origin /opt/Unity/accelerator/unity-accelerator-launch
--- /opt/Unity/accelerator/unity-accelerator-launch.origin
+++ /opt/Unity/accelerator/unity-accelerator-launch
@@ -22,7 +22,7 @@
export PATH
fi
pid="$(cat "$PIDFN" 2>/dev/null)"
- if ! kill -0 "$pid" 2>/dev/null; then
+ if ! kill -0 $pid 2>/dev/null; then
if $FOREGROUND; then
echo "$" > "$PIDFN"
exec "$AGENT" run --persist "$STORAGEDIR" >"${LOGFN}" 2>&1
@@ -37,7 +37,7 @@

status () {
pid="$(cat "$PIDFN" 2>/dev/null)"
- if kill -0 "$pid" 2>/dev/null; then
+ if kill -0 $pid 2>/dev/null; then
echo "${PRODUCT_SLUG} is running as $pid"
else
echo "${PRODUCT_SLUG} is not running" >&2

Thank you @shiena , that is clearly a bug in our recent change to prevent running multiple instances of the Accelerator. We’ll get this fixed up.

1 Like

@bradunity As I noticed later, when using Accelerator with Docker, unity-accelerator-launch set in CMD always has pid 1, so it will be caught in multiple launch inspection. This can be avoided by adding a comparison with your own pid.

~ # diff -u /opt/Unity/accelerator/unity-accelerator-launch.orig /opt/Unity/accelerator/unity-accelerator-launch
--- /opt/Unity/accelerator/unity-accelerator-launch.orig
+++ /opt/Unity/accelerator/unity-accelerator-launch
@@ -22,7 +22,7 @@
         export PATH
     fi
     pid="$(cat "$PIDFN" 2>/dev/null)"
-    if ! kill -0 $pid 2>/dev/null; then
+    if [ "$" == "$pid" ] || ! kill -0 $pid 2>/dev/null; then
         if $FOREGROUND; then
             echo "$" > "$PIDFN"
             exec "$AGENT" run --persist "$STORAGEDIR" >"${LOGFN}" 2>&1
1 Like