ByteInternet / hypernode-docker

Fast and easy Docker for Magento development
https://community.hypernode.io/hypernode-docker
35 stars 8 forks source link

nginx config is not reloaded #7

Closed peterjaap closed 6 years ago

peterjaap commented 6 years ago

The nginx config does not seem to reload when I change a file in ~/nginx/. Sanity check; when I add a file there with a deliberate mistake, on a production Hypernode this is what I'm getting;

app@83ezze-clientname-magweb-do:~/nginx$ echo "wutwut" > server.test && cat server.test
wutwut

Your Nginx configuration contains errors, please check
/data/web/nginx/nginx_error_output to see them.

app@83ezze-clientname-magweb-do:~/nginx$ cat nginx_error_output 
nginx: [emerg] unexpected end of file, expecting ";" or "}" in /etc/nginx/app/server.test:2
nginx: configuration file /etc/nginx/nginx.conf test failed

Your Nginx configuration contains errors, please check
/data/web/nginx/nginx_error_output to see them.

But when I do this in the Hypernode container, nada;

root@hypernode-deployment-66b9d66b54-hz7gj /data/web/nginx # echo "wutwut" > server.test && cat server.test
wutwut
root@hypernode-deployment-66b9d66b54-hz7gj /data/web/nginx # 

Also after restarting the nginx service, nothing happens;

cat /etc/my_init.d/60_restart_services.sh | grep nginx > restart_nginx.sh && bash restart_nginx.sh && rm restart_nginx.sh
peterjaap commented 6 years ago

Found a workaround;

cp -R /data/web/nginx/ssl /etc/nginx/app/ssl
cat /etc/my_init.d/60_restart_services.sh | grep nginx > restart_nginx.sh && bash restart_nginx.sh && rm restart_nginx.sh

It seems that the files from ~/nginx aren't read at all.

vdloo commented 6 years ago

Perhaps this has something to do with inotify in the docker fs, I'm pretty sure that doesn't work. There's a periodic cron to run /usr/bin/nginx_config_reloader manually to work around that, but if you're scripting against the system and expecting the inotify handler to trigger it when something is written to /data/web/nginx like it is on a real hypernode (or a Virtualbox vagrant, probably also doesn't work in lxc), the cron is not fast enough. Does it work if you run /usr/bin/nginx_config_reloader manually? Also see https://github.com/ByteInternet/nginx_config_reloader

peterjaap commented 6 years ago

@vdloo right! Yes, that does the trick. That seems to copy the content of /data/web/nginx to /etc/nginx/app. I'll just run /usr/bin/nginx_config_reloader after hypernode-ssl-config-generator. Thanks! :+1:

Edit; haha second sentence in the readme of the nginx_config_reloader repo :joy: