Run "nginx restart" automatically after "vagrant up" has completed

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Run "nginx restart" automatically after "vagrant up" has completed

James Newton
Hello Vagrant experts!

In this thread I asked how to copy the nginx folder out to Vagrant project folder, so that I can edit the server block definitions from the comfort of the host machine.

It turns out that, if I do this, when I run `vagrant up`, nginx starts, but fails to initialize the sites (presumably because the contents of the nginx folder is changed by Vagrant after nginx has loaded). The short term solution is to run...

vagrant ssh
sudo service nginx restart

... after `vagrant up`.

My question is: Is there a way to automate this restart of nginx? 

Can this be done through an entry in the Vagrantfile? Or would it be cleaner to set up a script that will run automatically on the guest server, and if so what would this script be and how would it be run?

Thanks in advance for all your enlightenment,

James

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/984f1523-3327-4ec4-b8cc-8ebb5a220ce3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Run "nginx restart" automatically after "vagrant up" has completed

Alvaro Miranda Aguilera
Sure.


Vagrant.configure("2") do |config|
  config.vm.provision "shell", run: "always", inline: "service nginx restart"
end

On Tue, Sep 12, 2017 at 11:07 AM, James Newton <[hidden email]> wrote:
Hello Vagrant experts!

In this thread I asked how to copy the nginx folder out to Vagrant project folder, so that I can edit the server block definitions from the comfort of the host machine.

It turns out that, if I do this, when I run `vagrant up`, nginx starts, but fails to initialize the sites (presumably because the contents of the nginx folder is changed by Vagrant after nginx has loaded). The short term solution is to run...

vagrant ssh
sudo service nginx restart

... after `vagrant up`.

My question is: Is there a way to automate this restart of nginx? 

Can this be done through an entry in the Vagrantfile? Or would it be cleaner to set up a script that will run automatically on the guest server, and if so what would this script be and how would it be run?

Thanks in advance for all your enlightenment,

James

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/984f1523-3327-4ec4-b8cc-8ebb5a220ce3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAHqq0eyS450mRe9rJcfum1a3tpkC3_UkHX_KqrY-%2BcDzaVBDjA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Run "nginx restart" automatically after "vagrant up" has completed

James Newton
Thanks Alvaro!  That works perfectly.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/a7109da7-5734-41f7-a2a0-cb5298ebc0b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Run "nginx restart" automatically after "vagrant up" has completed

Alvaro Miranda Aguilera
hello

can you share your project in github? perhaps all can be incorporated into the same script

Alvaro

On Wednesday, September 13, 2017 at 9:38:37 AM UTC+2, James Newton wrote:
Thanks Alvaro!  That works perfectly.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/608fc3dc-73e5-4790-a467-ed4ced7ffd25%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.