I want to setup a Vagrant configuration to create and launch an Ubuntu guest VM which will launch a supervisord
service within the VM after Vagrant up
. I'd like for this to work on Windows, Mac, and Linux hosts.
I have a supervisord.conf
file which I copy to the VM during provisioning (by copying to user space first and then copying to /etc/supervisor/
as in this answer). This config file includes these lines to serve a GUI interface on port 9001 (this port is forwarded to the host):
[inet_http_server]
port=9001
However, if I issue a command in the Vagrant provisioning script like service supervisor start
then this configuration is not correctly picked up. I can ssh into the VM and verify that the supervisor service is running, but the GUI is not available on port 9001. If I restart the service using ssh, then the GUI becomes available after restart.
That restarting the service causes it to pick up my config makes me think that the configuration wasn't available somehow when the service first started.
This answer seems to address a similar problem. So I tried also copying a file to /etc/init/supervisor.conf
:
# start supervisord on vagrant mounted
start on vagrant-mounted
exec service supervisor restart
This would cause upstart to restart the service when it receives the vagrant-mounted
event. However, even with this in place, supervisor did not appear to have started correctly.
I tested this upstart script by issuing sudo initctl emit vagrant-mounted
, and observed the supervisor service restart, and the GUI became available on 9001.
This makes me think that the vagrant-mounted
event probably occurred before the provisioning script was run.
Does anybody know if there's any other event I could predicate my upstart scripts on? Something that is emitted when vagrant provisioning is completed?
Also, is there any better or canonical way of launching a service in a vagrant VM? This all feels like I've gone down a rabbit hole and missed something really obvious.