vboxweb-service.sh assumes single instance of vboxwebsrv
Posted: 23. Aug 2017, 19:35
Hello,
Currently the vboxweb-service.sh init script assumes that only a single instance of vboxwebsrv will be running on the system – if another user starts their own instance of vboxwebsrv the script will fail to work properly (it will shut down instances it did not launch and/or will fail to create an instance of vboxwebsrv if any other user of the system has already launched it under their own account).
I experienced concurrency issues at boot when another user launched vboxwebsrv in their crontab with @reboot. vboxweb-service.sh only checks for the process name, not the userid under which the process is running so can report the service as defined in the config files ($VBOXWEB_USER, $VBOXWEB_HOST etc) has started when in fact it has not.
Attached is modified version of vboxweb-service.sh that addresses this issue - it ignores other instances of vboxwebsrv and limits itself to managing instances of vboxwebsrv launched as the user defined by VBOXWEB_USER in the config files. I'd appreciate feedback on my modifications before I submit it as a patch.
I also notice that vboxwebsrv does not exit if it can not bind a socket, is this a bug or by design? Not binding a socket does result in a fault in the log - though this seems odd as what is the point of a web service that cannot talk to the network? It also makes it harder to handle the situation where another process has bound the default socket. The modified vboxwebservice.sh attached doesn't address that scenario as the service does technically start up.
Longer term it may be neater for the vboxweb-service script to handle launching vboxweb under multiple different userids (I use multiple instances to segregate "production" VMs, which run under "vbox" user, from my experimental VMs which run under my personal account on the server, managed through phpvirtualbox - having them listed side by side under a single account increases the risk of accidentally stopping a "production" VM)
regards,
Arthur
Currently the vboxweb-service.sh init script assumes that only a single instance of vboxwebsrv will be running on the system – if another user starts their own instance of vboxwebsrv the script will fail to work properly (it will shut down instances it did not launch and/or will fail to create an instance of vboxwebsrv if any other user of the system has already launched it under their own account).
I experienced concurrency issues at boot when another user launched vboxwebsrv in their crontab with @reboot. vboxweb-service.sh only checks for the process name, not the userid under which the process is running so can report the service as defined in the config files ($VBOXWEB_USER, $VBOXWEB_HOST etc) has started when in fact it has not.
Attached is modified version of vboxweb-service.sh that addresses this issue - it ignores other instances of vboxwebsrv and limits itself to managing instances of vboxwebsrv launched as the user defined by VBOXWEB_USER in the config files. I'd appreciate feedback on my modifications before I submit it as a patch.
I also notice that vboxwebsrv does not exit if it can not bind a socket, is this a bug or by design? Not binding a socket does result in a fault in the log - though this seems odd as what is the point of a web service that cannot talk to the network? It also makes it harder to handle the situation where another process has bound the default socket. The modified vboxwebservice.sh attached doesn't address that scenario as the service does technically start up.
Longer term it may be neater for the vboxweb-service script to handle launching vboxweb under multiple different userids (I use multiple instances to segregate "production" VMs, which run under "vbox" user, from my experimental VMs which run under my personal account on the server, managed through phpvirtualbox - having them listed side by side under a single account increases the risk of accidentally stopping a "production" VM)
regards,
Arthur