Nginx doesn't restart on Ubuntu 16.04
iainhouston opened this issue · comments
Recently (perhaps after having vagrant box update
to latest installed version: 1.1.8?) Nginx will only be running after a vagrant provision
but not on subsequent vagrant up
or vagrant reload
. Otherwise it will be dead until I vagrant ssh
and sudo systemctl start nginx
after every time I vagrant up
or vagrant reload
.
The solution (to a "known bug" since Feb 2017) seems to be to wait for a bit on system (re)start as follows:
sudo su
mkdir /etc/systemd/system/nginx.service.d
printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" > /etc/systemd/system/nginx.service.d/override.conf
systemctl daemon-reload
systemctl restart nginx
Has anyone else been experiencing this? (Perhaps it is now time to try the official nginx Ansible role as Jeff suggests? (Although I haven't seen yet how to adapt my vagrant.config.yml
to do this yet.)
No, that's not the workaround. Nginx still fails to start automatically when I bring up the vm.
On bringing up the vm:
root@vagrant:/var/www/drupal/web# systemctl status nginx
* nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/nginx.service.d
`-override.conf
Active: inactive (dead)
Docs: man:nginx(8)
After manually staring Nginx:
root@vagrant:/var/www/drupal/web# systemctl start nginx
root@vagrant:/var/www/drupal/web# systemctl status nginx
* nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/nginx.service.d
`-override.conf
Active: active (running) since Thu 2018-05-03 06:40:36 UTC; 3s ago
Docs: man:nginx(8)
Process: 1873 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS)
Process: 1869 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status
Process: 1866 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exite
Main PID: 1872 (nginx)
CGroup: /system.slice/nginx.service
|-1872 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
`-1875 nginx: worker process
May 03 06:40:36 vagrant systemd[1]: Starting A high performance web server and a reverse proxy
May 03 06:40:36 vagrant systemd[1]: Started A high performance web server and a reverse proxy s
root@vagrant:/var/www/drupal/web#
Closing in favor of #154