Skip to contentSkip to conversation

cleanup and restart crashed vnc server

PATCH In review Bill Randle 2 participants 6 messages Aug 17, 2016 – Aug 31, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cleanup and restart crashed vnc server

Use a common script to check for a running vnc server, and if not running cleanup dangling lock files and restart the server.

[YOCTO #8210]

---
 bin/checkvnc                                                   | 10 ++++++++++
 .../site-packages/autobuilder/buildsteps/RunESDKSanityTests.py |  3 +--
 .../site-packages/autobuilder/buildsteps/RunOeSelftest.py      |  3 +--
 .../site-packages/autobuilder/buildsteps/RunSDKSanityTests.py  |  3 +--
 .../site-packages/autobuilder/buildsteps/RunSanityTests.py     |  3 +--
 5 files changed, 14 insertions(+), 8 deletions(-)
 create mode 100755 bin/checkvnc
bin/checkvnc new file +10 -0
new file mode 100755
index 0000000..574ba48
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# check if vnc server is running, and if not, cleanup and restart
+#
+pid=$(pidof Xvnc)
+if [[ $? != 0 ]]; then
+    echo "Xvnc not running, attempting restart"
+    vncserver -kill :1
+    vncserver
+fi
lib/python2.7/site-packages/autobuilder/buildsteps/RunESDKSanityTests.py +1 -2
index 7471d3d..c16c8c2 100644
@@ -47,8 +47,7 @@ class RunESDKSanityTests(BitbakeShellCommand):
         layerversion = self.getProperty("layerversion_core")
         command = ""
         command = command + ". ./oe-init-build-env; "
-        command = command + "netstat -an | grep -q 5901 ;"
-        command = command + 'if [ $? -ne 0 ]; then echo "Starting a VNC server on :1"; vncserver :1; else echo "Will use a VNC server already running on :1"; fi;'
+        command = command + "checkvnc; "
         if layerversion and int(layerversion) >= 7:
             command = command + "echo 'INHERIT += \"testsdk\"' >> ./conf/auto.conf;"
             command = command + "echo 'TEST_QEMUBOOT_TIMEOUT = \"1500\"' >> ./conf/auto.conf;"
lib/python2.7/site-packages/autobuilder/buildsteps/RunOeSelftest.py +1 -2
index 809bcc3..84d32fe 100644
@@ -31,8 +31,7 @@ class RunOeSelftest(ShellCommand):
     def start(self):
         self.command = ""
         self.command += ". ./oe-init-build-env; "
-        self.command += "netstat -an | grep -q 5901 ;"
-        self.command += "if [ $? -ne 0 ]; then echo 'Starting a VNC server on :1'; vncserver :1; else echo 'Will use a VNC server already running on :1'; fi;"
+        self.command += "checkvnc; "
         if self.tests == None:
             self.command += "if [ -d ../meta-selftest ]; then export DISPLAY=:1; oe-selftest --run-all-tests; else echo 'Skipping step - no meta-selftest layer here'; fi"
         else:
lib/python2.7/site-packages/autobuilder/buildsteps/RunSDKSanityTests.py +1 -2
index 9b6eb5b..6fb3127 100644
@@ -47,8 +47,7 @@ class RunSDKSanityTests(BitbakeShellCommand):
         layerversion = self.getProperty("layerversion_core")
         command = ""
         command = command + ". ./oe-init-build-env; "
-        command = command + "netstat -an | grep -q 5901 ;"
-        command = command + 'if [ $? -ne 0 ]; then echo "Starting a VNC server on :1"; vncserver :1; else echo "Will use a VNC server already running on :1"; fi;'
+        command = command + "checkvnc; "
         if layerversion and int(layerversion) >= 6:
             command = command + "echo 'INHERIT += \"testimage\"' >> ./conf/auto.conf;"
             command = command + "echo 'TEST_QEMUBOOT_TIMEOUT = \"1500\"' >> ./conf/auto.conf;"
lib/python2.7/site-packages/autobuilder/buildsteps/RunSanityTests.py +1 -2
index 4fa6dac..81e20cd 100644
@@ -48,8 +48,7 @@ class RunSanityTests(BitbakeShellCommand):
         distro = self.getProperty("DISTRO")
         command = ""
         command = command + ". ./oe-init-build-env; "
-        command = command + "netstat -an | grep -q 5901 ;"
-        command = command + 'if [ $? -ne 0 ]; then echo "Starting a VNC server on :1"; vncserver :1; else echo "Will use a VNC server already running on :1"; fi;'
+        command = command + "checkvnc; "
         if distro == "poky-lsb" and layerversion and int(layerversion) < 6:
             command = "echo 'Skipping step.'"
         elif layerversion and int(layerversion) > 1:
Signature · 1 line
2.5.5
#1 lore raw
Quoted 27 lines · Bill Randle

Use a common script to check for a running vnc server, and if not running
cleanup dangling lock files and restart the server.

[YOCTO #8210]

---
 bin/checkvnc                                                   | 10
++++++++++
 .../site-packages/autobuilder/buildsteps/RunESDKSanityTests.py |  3

+--
 .../site-packages/autobuilder/buildsteps/RunOeSelftest.py      |  3
+--
 .../site-packages/autobuilder/buildsteps/RunSDKSanityTests.py  |  3
+--
 .../site-packages/autobuilder/buildsteps/RunSanityTests.py     |  3
+--
 5 files changed, 14 insertions(+), 8 deletions(-)

 create mode 100755 bin/checkvnc

bin/checkvnc new file +0 -0
new file mode 100755
index 0000000..574ba48

bin/checkvnc line 9

Quoted 9 lines
bin/checkvnc new file +9 -0
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# check if vnc server is running, and if not, cleanup and restart
+#
+pid=$(pidof Xvnc)
+if [[ $? != 0 ]]; then
+    echo "Xvnc not running, attempting restart"
+    vncserver -kill :1
+    vncserver

The vncserver is currently started with vncserver :1, whereas this script just calls vncserver — is that intentional/desirable?

Would it be a little cleaner/more robust if we didn't assume only one Xvnc instance was running and instead write the pid of the process we start to a file and use that file to check the status?

Regards,

Joshua

Quoted 91 lines
bin/checkvnc new file +1 -0
+fi
(quoted diff) +0 -0

packages/autobuilder/buildsteps/RunESDKSanityTests.py b/lib/python2.7/site- packages/autobuilder/buildsteps/RunESDKSanityTests.py index 7471d3d..c16c8c2 100644
--- a/lib/python2.7/site- packages/autobuilder/buildsteps/RunESDKSanityTests.py +++ b/lib/python2.7/site- packages/autobuilder/buildsteps/RunESDKSanityTests.py

(quoted diff) +0 -0
@@ -47,8 +47,7 @@ class RunESDKSanityTests(BitbakeShellCommand):
          layerversion = self.getProperty("layerversion_core")

         command = ""
         command = command + ". ./oe-init-build-env; "
-        command = command + "netstat -an | grep -q 5901 ;" -        command = command + 'if [ $? -ne 0 ]; then echo "Starting a VNC server on :1"; vncserver :1; else echo "Will use a VNC server already running on :1"; fi;'
+        command = command + "checkvnc; "
         if layerversion and int(layerversion) >= 7:
             command = command + "echo 'INHERIT += \"testsdk\"' >> ./conf/auto.conf;"
             command = command + "echo 'TEST_QEMUBOOT_TIMEOUT = \"1500\"' >> ./conf/auto.conf;"

(quoted diff) +0 -0

packages/autobuilder/buildsteps/RunOeSelftest.py b/lib/python2.7/site-packages/autobuilder/buildsteps/RunOeSelftest.py index 809bcc3..84d32fe 100644
--- a/lib/python2.7/site- packages/autobuilder/buildsteps/RunOeSelftest.py
+++ b/lib/python2.7/site- packages/autobuilder/buildsteps/RunOeSelftest.py

(quoted diff) +0 -0
@@ -31,8 +31,7 @@ class RunOeSelftest(ShellCommand):

     def start(self):
         self.command = ""
         self.command += ". ./oe-init-build-env; "
-        self.command += "netstat -an | grep -q 5901 ;"
-        self.command += "if [ $? -ne 0 ]; then echo 'Starting a VNC server on :1'; vncserver :1; else echo 'Will use a VNC server already running on :1'; fi;"
+        self.command += "checkvnc; "
         if self.tests == None:
             self.command += "if [ -d ../meta-selftest ]; then export DISPLAY=:1; oe-selftest --run-all-tests; else echo 'Skipping step - no meta-selftest layer here'; fi"
         else:

(quoted diff) +0 -0

packages/autobuilder/buildsteps/RunSDKSanityTests.py b/lib/python2.7/site- packages/autobuilder/buildsteps/RunSDKSanityTests.py index 9b6eb5b..6fb3127 100644
--- a/lib/python2.7/site- packages/autobuilder/buildsteps/RunSDKSanityTests.py +++ b/lib/python2.7/site- packages/autobuilder/buildsteps/RunSDKSanityTests.py

(quoted diff) +0 -0
@@ -47,8 +47,7 @@ class RunSDKSanityTests(BitbakeShellCommand):
          layerversion = self.getProperty("layerversion_core")

         command = ""
         command = command + ". ./oe-init-build-env; "
-        command = command + "netstat -an | grep -q 5901 ;" -        command = command + 'if [ $? -ne 0 ]; then echo "Starting a VNC server on :1"; vncserver :1; else echo "Will use a VNC server already running on :1"; fi;'
+        command = command + "checkvnc; "
         if layerversion and int(layerversion) >= 6:
             command = command + "echo 'INHERIT += \"testimage\"' >> ./conf/auto.conf;"
             command = command + "echo 'TEST_QEMUBOOT_TIMEOUT = \"1500\"' >> ./conf/auto.conf;"

(quoted diff) +0 -0

packages/autobuilder/buildsteps/RunSanityTests.py
b/lib/python2.7/site-
packages/autobuilder/buildsteps/RunSanityTests.py
index 4fa6dac..81e20cd 100644
--- a/lib/python2.7/site-
packages/autobuilder/buildsteps/RunSanityTests.py
+++ b/lib/python2.7/site-
packages/autobuilder/buildsteps/RunSanityTests.py

lib/python2.7/site-packages/autobuilder/buildsteps/RunSanityTests.py +0 -0
@@ -48,8 +48,7 @@ class RunSanityTests(BitbakeShellCommand):
          distro = self.getProperty("DISTRO")

         command = ""
         command = command + ". ./oe-init-build-env; "
-        command = command + "netstat -an | grep -q 5901 ;" -        command = command + 'if [ $? -ne 0 ]; then echo "Starting a VNC server on :1"; vncserver :1; else echo "Will use a VNC server already running on :1"; fi;'
+        command = command + "checkvnc; "
         if distro == "poky-lsb" and layerversion and int(layerversion) < 6:
             command = "echo 'Skipping step.'"
         elif layerversion and int(layerversion) > 1:

#2 lore raw

On Wed, 2016-08-17 at 16:59 +0100, Joshua G Lock wrote:

On Tue, 2016-08-16 at 17:09 -0700, Bill Randle wrote:

Use a common script to check for a running vnc server, and if not running
cleanup dangling lock files and restart the server.

[YOCTO #8210]

---
 bin/checkvnc                                                   | 10
++++++++++
 .../site-packages/autobuilder/buildsteps/RunESDKSanityTests.py |  3
+--
 .../site-packages/autobuilder/buildsteps/RunOeSelftest.py      |  3
+--
 .../site-packages/autobuilder/buildsteps/RunSDKSanityTests.py  |  3
+--
 .../site-packages/autobuilder/buildsteps/RunSanityTests.py     |  3
+--
 5 files changed, 14 insertions(+), 8 deletions(-)
 create mode 100755 bin/checkvnc
bin/checkvnc new file +9 -0
new file mode 100755
index 0000000..574ba48
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# check if vnc server is running, and if not, cleanup and restart
+#
+pid=$(pidof Xvnc)
+if [[ $? != 0 ]]; then
+    echo "Xvnc not running, attempting restart"
+    vncserver -kill :1
+    vncserver

The vncserver is currently started with vncserver :1, whereas this script just calls vncserver — is that intentional/desirable?

Would it be a little cleaner/more robust if we didn't assume only one Xvnc instance was running and instead write the pid of the process we start to a file and use that file to check the status?

Regards,

Joshua

The vncserver program is a shell script and uses :1 as the default display.

The pid of Xvnc is written to a file already. The problem is, if Xvmc crashes, the pid file (and lock file) are left around, so just looking at the pid file existance, you can't tell if it's actually running or not.

- Bill

+fi

(quoted diff) +0 -0

packages/autobuilder/buildsteps/RunESDKSanityTests.py b/lib/python2.7/site- packages/autobuilder/buildsteps/RunESDKSanityTests.py index 7471d3d..c16c8c2 100644
--- a/lib/python2.7/site- packages/autobuilder/buildsteps/RunESDKSanityTests.py +++ b/lib/python2.7/site- packages/autobuilder/buildsteps/RunESDKSanityTests.py @@ -47,8 +47,7 @@ class RunESDKSanityTests(BitbakeShellCommand):
layerversion = self.getProperty("layerversion_core") command = ""
command = command + ". ./oe-init-build-env; "
- command = command + "netstat -an | grep -q 5901 ;"
- command = command + 'if [ $? -ne 0 ]; then echo "Starting a
VNC server on :1"; vncserver :1; else echo "Will use a VNC server already running on :1"; fi;'
+ command = command + "checkvnc; "
if layerversion and int(layerversion) >= 7:
command = command + "echo 'INHERIT += \"testsdk\"' >>
./conf/auto.conf;"
command = command + "echo 'TEST_QEMUBOOT_TIMEOUT =
\"1500\"' >> ./conf/auto.conf;"

(quoted diff) +0 -0

packages/autobuilder/buildsteps/RunOeSelftest.py b/lib/python2.7/site-packages/autobuilder/buildsteps/RunOeSelftest.py index 809bcc3..84d32fe 100644
--- a/lib/python2.7/site- packages/autobuilder/buildsteps/RunOeSelftest.py
+++ b/lib/python2.7/site- packages/autobuilder/buildsteps/RunOeSelftest.py
@@ -31,8 +31,7 @@ class RunOeSelftest(ShellCommand):
def start(self):
self.command = ""
self.command += ". ./oe-init-build-env; "
- self.command += "netstat -an | grep -q 5901 ;"
- self.command += "if [ $? -ne 0 ]; then echo 'Starting a VNC
server on :1'; vncserver :1; else echo 'Will use a VNC server already running on :1'; fi;"
+ self.command += "checkvnc; "

         if self.tests == None:
             self.command += "if [ -d ../meta-selftest ]; then export

DISPLAY=:1; oe-selftest --run-all-tests; else echo 'Skipping step - no meta-selftest layer here'; fi"
else:

(quoted diff) +0 -0

packages/autobuilder/buildsteps/RunSDKSanityTests.py b/lib/python2.7/site- packages/autobuilder/buildsteps/RunSDKSanityTests.py index 9b6eb5b..6fb3127 100644
--- a/lib/python2.7/site- packages/autobuilder/buildsteps/RunSDKSanityTests.py
+++ b/lib/python2.7/site- packages/autobuilder/buildsteps/RunSDKSanityTests.py
@@ -47,8 +47,7 @@ class RunSDKSanityTests(BitbakeShellCommand):
layerversion = self.getProperty("layerversion_core") command = ""
command = command + ". ./oe-init-build-env; "
- command = command + "netstat -an | grep -q 5901 ;"
- command = command + 'if [ $? -ne 0 ]; then echo "Starting a
VNC server on :1"; vncserver :1; else echo "Will use a VNC server already running on :1"; fi;'
+ command = command + "checkvnc; "
if layerversion and int(layerversion) >= 6:
command = command + "echo 'INHERIT += \"testimage\"' >>
./conf/auto.conf;"
command = command + "echo 'TEST_QEMUBOOT_TIMEOUT =
\"1500\"' >> ./conf/auto.conf;"

(quoted diff) +0 -0

packages/autobuilder/buildsteps/RunSanityTests.py b/lib/python2.7/site- packages/autobuilder/buildsteps/RunSanityTests.py
index 4fa6dac..81e20cd 100644
--- a/lib/python2.7/site- packages/autobuilder/buildsteps/RunSanityTests.py
+++ b/lib/python2.7/site- packages/autobuilder/buildsteps/RunSanityTests.py
@@ -48,8 +48,7 @@ class RunSanityTests(BitbakeShellCommand):
distro = self.getProperty("DISTRO")
command = ""
command = command + ". ./oe-init-build-env; "
- command = command + "netstat -an | grep -q 5901 ;"
- command = command + 'if [ $? -ne 0 ]; then echo "Starting a
VNC server on :1"; vncserver :1; else echo "Will use a VNC server already running on :1"; fi;'
+ command = command + "checkvnc; "

         if distro == "poky-lsb" and layerversion and

int(layerversion) < 6:
command = "echo 'Skipping step.'"
elif layerversion and int(layerversion) > 1:

#3 lore raw
Quoted 8 lines · William C
Quoted 5 lines · Joshua G Lock
Quoted 4 lines · Bill Randle

Use a common script to check for a running vnc server, and if not running
cleanup dangling lock files and restart the server.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

[YOCTO #8210]

Quoted 1 line
Quoted 1 line
Quoted 1 line

---

Quoted 1 line
Quoted 1 line
Quoted 1 line

 bin/checkvnc                                                   |

10

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

++++++++++

Quoted 1 line
Quoted 1 line
Quoted 1 line

 .../site-packages/autobuilder/buildsteps/RunESDKSanityTests.py

|  3

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+--

Quoted 1 line
Quoted 1 line
Quoted 1 line

 .../site-

packages/autobuilder/buildsteps/RunOeSelftest.py      |  3

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+--

Quoted 1 line
Quoted 1 line
Quoted 1 line

 .../site-

packages/autobuilder/buildsteps/RunSDKSanityTests.py  |  3

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+--

Quoted 1 line
Quoted 1 line
Quoted 1 line

 .../site-

packages/autobuilder/buildsteps/RunSanityTests.py     |  3

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

+--

 5 files changed, 14 insertions(+), 8 deletions(-)

 create mode 100755 bin/checkvnc

bin/checkvnc new file +2 -0
new file mode 100755
index 0000000..574ba48
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+# check if vnc server is running, and if not, cleanup and

restart

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
bin/checkvnc new file +6 -0
+#
+pid=$(pidof Xvnc)
+if [[ $? != 0 ]]; then
+    echo "Xvnc not running, attempting restart"
+    vncserver -kill :1
+    vncserver
Quoted 2 lines

The vncserver is currently started with vncserver :1, whereas

this

Quoted 3 lines
Quoted 3 lines

script just calls vncserver — is that intentional/desirable?

Quoted 1 line
Quoted 1 line

Would it be a little cleaner/more robust if we didn't assume only

one

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Xvnc instance was running and instead write the pid of the process

we

Quoted 4 lines
Quoted 4 lines

start to a file and use that file to check the status?

Regards,

Quoted 8 lines
Quoted 8 lines

Joshua

The vncserver program is a shell script and uses :1 as the default

display.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

The pid of Xvnc is written to a file already. The problem is, if Xvmc

crashes, the pid file (and lock file) are left around, so just looking at the pid file existance, you can't tell if it's actually running or not.

Quoted 1 line

Can we read the pid from the pidfile and do the tidy up if the process isn't running? My main concern here is that we assume only a single instance of Xvnc is running, I'm not sure if that is a safe assumption to make?

Thanks,

Joshua

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

    - Bill

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

+fi

(quoted diff) +0 -0

packages/autobuilder/buildsteps/RunESDKSanityTests.py b/lib/python2.7/site- packages/autobuilder/buildsteps/RunESDKSanityTests.py index 7471d3d..c16c8c2 100644
--- a/lib/python2.7/site- packages/autobuilder/buildsteps/RunESDKSanityTests.py
+++ b/lib/python2.7/site- packages/autobuilder/buildsteps/RunESDKSanityTests.py
@@ -47,8 +47,7 @@ class RunESDKSanityTests(BitbakeShellCommand):
         layerversion = self.getProperty("layerversion_core") command = ""
         command = command + ". ./oe-init-build-env; "
-        command = command + "netstat -an | grep -q 5901 ;" -        command = command + 'if [ $? -ne 0 ]; then echo "Starting a VNC server on :1"; vncserver :1; else echo "Will use a VNC server already running on :1"; fi;'
+        command = command + "checkvnc; "
         if layerversion and int(layerversion) >= 7:
             command = command + "echo 'INHERIT += \"testsdk\"' >> ./conf/auto.conf;"
             command = command + "echo 'TEST_QEMUBOOT_TIMEOUT = \"1500\"' >> ./conf/auto.conf;"

(quoted diff) +0 -0

packages/autobuilder/buildsteps/RunOeSelftest.py b/lib/python2.7/site-packages/autobuilder/buildsteps/RunOeSelftest.py index 809bcc3..84d32fe 100644
--- a/lib/python2.7/site- packages/autobuilder/buildsteps/RunOeSelftest.py
+++ b/lib/python2.7/site- packages/autobuilder/buildsteps/RunOeSelftest.py
@@ -31,8 +31,7 @@ class RunOeSelftest(ShellCommand):
     def start(self):
         self.command = ""
         self.command += ". ./oe-init-build-env; "
-        self.command += "netstat -an | grep -q 5901 ;"
-        self.command += "if [ $? -ne 0 ]; then echo 'Starting a VNC server on :1'; vncserver :1; else echo 'Will use a VNC server already running on :1'; fi;"
+        self.command += "checkvnc; "
         if self.tests == None:
             self.command += "if [ -d ../meta-selftest ]; then export DISPLAY=:1; oe-selftest --run-all-tests; else echo 'Skipping step - no meta-selftest layer here'; fi"
         else:

(quoted diff) +0 -0

packages/autobuilder/buildsteps/RunSDKSanityTests.py b/lib/python2.7/site- packages/autobuilder/buildsteps/RunSDKSanityTests.py index 9b6eb5b..6fb3127 100644
--- a/lib/python2.7/site- packages/autobuilder/buildsteps/RunSDKSanityTests.py
+++ b/lib/python2.7/site- packages/autobuilder/buildsteps/RunSDKSanityTests.py
@@ -47,8 +47,7 @@ class RunSDKSanityTests(BitbakeShellCommand):
         layerversion = self.getProperty("layerversion_core") command = ""
         command = command + ". ./oe-init-build-env; "
-        command = command + "netstat -an | grep -q 5901 ;" -        command = command + 'if [ $? -ne 0 ]; then echo "Starting a VNC server on :1"; vncserver :1; else echo "Will use a VNC server already running on :1"; fi;'
+        command = command + "checkvnc; "
         if layerversion and int(layerversion) >= 6:
             command = command + "echo 'INHERIT += \"testimage\"' >> ./conf/auto.conf;"
             command = command + "echo 'TEST_QEMUBOOT_TIMEOUT = \"1500\"' >> ./conf/auto.conf;"

(quoted diff) +0 -0

packages/autobuilder/buildsteps/RunSanityTests.py b/lib/python2.7/site- packages/autobuilder/buildsteps/RunSanityTests.py
index 4fa6dac..81e20cd 100644
--- a/lib/python2.7/site- packages/autobuilder/buildsteps/RunSanityTests.py
+++ b/lib/python2.7/site- packages/autobuilder/buildsteps/RunSanityTests.py
@@ -48,8 +48,7 @@ class RunSanityTests(BitbakeShellCommand):
         distro = self.getProperty("DISTRO")
         command = ""
         command = command + ". ./oe-init-build-env; "
-        command = command + "netstat -an | grep -q 5901 ;" -        command = command + 'if [ $? -ne 0 ]; then echo "Starting a VNC server on :1"; vncserver :1; else echo "Will use a VNC server already running on :1"; fi;'
+        command = command + "checkvnc; "
         if distro == "poky-lsb" and layerversion and int(layerversion) < 6:
             command = "echo 'Skipping step.'"
         elif layerversion and int(layerversion) > 1:

#4 lore raw

On Wed, 2016-08-17 at 17:12 +0100, Joshua G Lock wrote:
On Wed, 2016-08-17 at 16:09 +0000, Randle, William C wrote:
On Wed, 2016-08-17 at 16:59 +0100, Joshua G Lock wrote:

On Tue, 2016-08-16 at 17:09 -0700, Bill Randle wrote:

Use a common script to check for a running vnc server, and if not running
cleanup dangling lock files and restart the server.

[YOCTO #8210]

---
 bin/checkvnc                                                   | 10
++++++++++
 .../site-packages/autobuilder/buildsteps/RunESDKSanityTests.py |  3
+--
 .../site-packages/autobuilder/buildsteps/RunOeSelftest.py      |  3
+--
 .../site-packages/autobuilder/buildsteps/RunSDKSanityTests.py  |  3
+--
 .../site-packages/autobuilder/buildsteps/RunSanityTests.py     |  3
+--
 5 files changed, 14 insertions(+), 8 deletions(-)
 create mode 100755 bin/checkvnc
bin/checkvnc new file +9 -0
new file mode 100755
index 0000000..574ba48
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# check if vnc server is running, and if not, cleanup and restart
+#
+pid=$(pidof Xvnc)
+if [[ $? != 0 ]]; then
+    echo "Xvnc not running, attempting restart"
+    vncserver -kill :1
+    vncserver

The vncserver is currently started with vncserver :1, whereas this script just calls vncserver — is that intentional/desirable?

Would it be a little cleaner/more robust if we didn't assume only one Xvnc instance was running and instead write the pid of the process we start to a file and use that file to check the status?

Regards,

Joshua

The vncserver program is a shell script and uses :1 as the default display.

The pid of Xvnc is written to a file already. The problem is, if Xvmc crashes, the pid file (and lock file) are left around, so just looking at the pid file existance, you can't tell if it's actually running or not.

Can we read the pid from the pidfile and do the tidy up if the process isn't running? My main concern here is that we assume only a single instance of Xvnc is running, I'm not sure if that is a safe assumption to make?

I'll take a look at it. You can hold off merging this one for now.

-Bill

Thanks,

Joshua

#5 lore raw
In reply to Joshua G Lock
Quoted 5 lines · Joshua G Lock
Quoted 4 lines · William C
Quoted 2 lines · Joshua G Lock
Quoted 1 line · Bill Randle
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Use a common script to check for a running vnc server, and if

not

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

running
cleanup dangling lock files and restart the server.

[YOCTO #8210]

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

---

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

 bin/checkvnc

 | 10

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

++++++++++

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

 .../site-packages/autobuilder/buildsteps/RunESDKSanityTests.py

|  3

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+--

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

 .../site-

packages/autobuilder/buildsteps/RunOeSelftest.py      |  3

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+--

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

 .../site-

packages/autobuilder/buildsteps/RunSDKSanityTests.py  |  3

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+--

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

 .../site-

packages/autobuilder/buildsteps/RunSanityTests.py     |  3

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

+--

 5 files changed, 14 insertions(+), 8 deletions(-)

 create mode 100755 bin/checkvnc

bin/checkvnc new file +2 -0
new file mode 100755
index 0000000..574ba48
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+# check if vnc server is running, and if not, cleanup and

restart

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
bin/checkvnc new file +6 -0
+#
+pid=$(pidof Xvnc)
+if [[ $? != 0 ]]; then
+    echo "Xvnc not running, attempting restart"
+    vncserver -kill :1
+    vncserver
Quoted 2 lines
Quoted 2 lines

The vncserver is currently started with vncserver :1, whereas

this

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

script just calls vncserver — is that intentional/desirable?

Quoted 1 line
Quoted 1 line
Quoted 1 line

Would it be a little cleaner/more robust if we didn't assume only

one

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Xvnc instance was running and instead write the pid of the

process we

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

start to a file and use that file to check the status?

Regards,

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Joshua

Quoted 1 line

The vncserver program is a shell script and uses :1 as the default

display.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

The pid of Xvnc is written to a file already. The problem is, if

Xvmc crashes, the pid file (and lock file) are left around, so just looking at the pid file existance, you can't tell if it's actually running or not.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Can we read the pid from the pidfile and do the tidy up if the

process isn't running? My main concern here is that we assume only a single instance of Xvnc is running, I'm not sure if that is a safe assumption to make?

It turns out we implicitly assume only one vncserver is running (on display 1) in several places throughout the AB codebase. Therefore I've pushed this change to master.

Thanks,

Joshua