Discussion:
[Supervisor-users] Trying to start vncserver using supervisord
Debnath Sinha
2013-10-03 21:11:49 UTC
Permalink
I'm trying to start vncserver inside an lxc using supervisord. Since
supervisord is starting as root, I have added user=ubuntu to the config to
run it as "ubuntu" user.
Here is the config:

[program:vnc]
directory=/
user=ubuntu
environment=HOME="/home/ubuntu",USER="ubuntu"
priority=901
command=/usr/bin/vncserver -fg -geometry 1024x768 :1

However, it is not finding the password file in /home/ubuntu/.vnc/passwd,
my question is whether I need to do something special to set $HOME to
/home/ubuntu or whether I should expect these to bet set when I asked
supervisor to run it as user=ubuntu?
Is setting user=ubuntu the same as doing: su ubuntu; <cmd>?

Thanks,
-Debnath
Timothy Jones
2013-10-03 21:38:50 UTC
Permalink
My first inclination would be to have supervisor run "sudo -u ubuntu /usr/bin/vncserver -fg -geometry 1024x768 :1".

In the case of vncserver, you will run into another problem. If vncserver dies unexpectedly, the 2nd instance of vncserver that supervisor tries to start will not stay up, because the lock file /tmp/.X1-lock will still exist from the first instance, as follows:
Warning: hostname:1 is taken because of /tmp/.X1-lock
Remove this file if there is no X server hostname:1
A VNC server is already running as :1

Because of this vncserver-specific complication, I would go even further and suggest that supervisor should run a shell script that does this cleanup (rm /tmp/.X1-lock), set (and export) up your environment variables, and then 'exec vncserver ....'.

The 'exec' is to make sure that the vncserver process overlays the shell script PID, and does not result in an intermediate subshell between supervisor and vncserver. This way, the vncserver remains a direct child process of supervisor, not a grandchild. This is important because supervisor sends its termination signals only to its direct children.

Hope it helps!



tlj

From: supervisor-users-***@lists.supervisord.org [mailto:supervisor-users-***@lists.supervisord.org] On Behalf Of Debnath Sinha
Sent: Thursday, October 03, 2013 5:12 PM
To: supervisor-***@lists.supervisord.org
Subject: [Supervisor-users] Trying to start vncserver using supervisord

I'm trying to start vncserver inside an lxc using supervisord. Since supervisord is starting as root, I have added user=ubuntu to the config to run it as "ubuntu" user.
Here is the config:



[program:vnc]

directory=/

user=ubuntu

environment=HOME="/home/ubuntu",USER="ubuntu"

priority=901

command=/usr/bin/vncserver -fg -geometry 1024x768 :1
However, it is not finding the password file in /home/ubuntu/.vnc/passwd, my question is whether I need to do something special to set $HOME to /home/ubuntu or whether I should expect these to bet set when I asked supervisor to run it as user=ubuntu?
Is setting user=ubuntu the same as doing: su ubuntu; <cmd>?

Thanks,
-Debnath
Matthew Hall
2013-10-03 22:17:21 UTC
Permalink
Post by Timothy Jones
The 'exec' is to make sure that the vncserver process overlays the shell
script PID, and does not result in an intermediate subshell between
supervisor and vncserver. This way, the vncserver remains a direct child
process of supervisor, not a grandchild. This is important because
supervisor sends its termination signals only to its direct children.
Supervisor could greatly benefit from a small extension to allow sending its
kill signals to the child's process group (by just taking the negative
absolute value of the child PID). This would make it much more reliable for
some of my applications of Supervisor as well as what's being discussed here.

Matthew.
Chris McDonough
2013-10-03 23:11:57 UTC
Permalink
Post by Matthew Hall
Post by Timothy Jones
The 'exec' is to make sure that the vncserver process overlays the shell
script PID, and does not result in an intermediate subshell between
supervisor and vncserver. This way, the vncserver remains a direct child
process of supervisor, not a grandchild. This is important because
supervisor sends its termination signals only to its direct children.
Supervisor could greatly benefit from a small extension to allow sending its
kill signals to the child's process group (by just taking the negative
absolute value of the child PID). This would make it much more reliable for
some of my applications of Supervisor as well as what's being discussed here.
See the "killasgroup" program option.

- C

Loading...