简体   繁体   English

从Rails应用程序中重新加载Nginx配置

[英]Reloading nginx config from within a rails app

I have a multi-app system running on a centOS box, that consists of our main app and a deployer app. 我有一个在centOS框上运行的多应用程序系统,该系统包含我们的主应用程序和一个部署程序应用程序。 when a client wants a new instance of our app, they use our deployer, fill in some info and the new install is created on our server. 当客户想要我们的应用程序的新实例时,他们使用我们的部署程序,填写一些信息,然后在我们的服务器上创建新的安装。 the issue i am having is that i can't get nginx to reload it's config file automatically. 我遇到的问题是我无法让Nginx自动重新加载它的配置文件。 so after the deploy when visiting the new app we receive a 404 until i reload manually. 因此,在部署后访问新应用程序时,我们会收到404,直到我手动重新加载。

I've tried a few different ways including chmod /opt/nginx/sbin/nginx to 777, chmod the install script and deployer app to 777, 我尝试了几种不同的方法,包括将chmod / opt / nginx / sbin / nginx设置为777,将chmod安装脚本和部署程序应用程序设置为777,

the script goes like this: 脚本如下所示:

#create install directory -- works correctly
#copy files over -- works correctly
#run install script
##-- and then at this point i've tried multiple lines, including:
system("nginx -s reload") ## this works manually
system("/etc/init.d/nginx reload") ## this works manually

i've followed directions here: Restart nginx without sudo? 我在这里按照指示进行: 不使用sudo重启nginx吗? to create a script to run without a sudo password and then tried this: 创建一个无需sudo密码即可运行的脚本,然后尝试执行以下操作:

system("sudo /var/www/vhosts/deployer/lib/nginx_reload")

nothing seems to work, i'm assuming this is a permissions error, but maybe i'm wrong, if anyone could point me in any direction, that would be very helpful since i've been trying to figure this out for a few days too long and i'm fresh out of new ideas 似乎没有任何效果,我假设这是一个权限错误,但是也许我错了,如果有人可以向我指出任何方向,那将非常有帮助,因为我已经尝试了几天太久了,我对新想法一无所知

sudo /etc/init.d/nginx reload

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM