예제 #1
0
def restart():
    print('Restarting nginx:', end=' ')
    try:
        sudo.nginx('-p', CONF_DIR, '-c',
                   os.path.join(CONF_DIR, 'nginx.conf'),
                   '-s', 'stop')
    except ErrorReturnCode:
        pass  # ignore
    finally:
        try:
            sh.nginx('-p', CONF_DIR, '-c',
                     os.path.join(CONF_DIR, 'nginx.conf'))
        except ErrorReturnCode:
            print(colored('failed', 'red', attrs=['bold']) + '.')
        else:
            print(colored('nginx', 'green', attrs=['bold']) + '.')
예제 #2
0
파일: ng.py 프로젝트: fohnwind/fae
    def save(self):
        if self.name and self.ip:
            os.chdir('/home/fohnwind/ng/conf/')
            filename = self.name + "." + DefaultConfig.SITE_NAME + ".conf"

            fp = open(filename, 'w')

            conf = Template(filename="ngconf.default").render(ip=self.ip, name=self.name)

            print >> fp, conf
            fp.close()

            nginx("-s","reload")

            return True

        return False
예제 #3
0
파일: Source.py 프로젝트: carriercomm/Sdp
    def Proxy(self):
        ngx_user_conf = os.path.join(Config.PROXY_DIR, self.name) + '.conf'
        ngx_conf_content = r'''server {
    listen 80;
    server_name %s;
    index index.htm index.html index.php index.jsp;
    location / {
        proxy_pass http://%s:%s/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}''' %(self.dn, self.ip, int(self.port))
        with open(ngx_user_conf, 'w') as f:
            f.write(ngx_conf_content)
        from sh import nginx
        nginx('-s', 'reload')
예제 #4
0
파일: Source.py 프로젝트: feitianyiren/Sdp
    def Proxy(self):
        ngx_user_conf = os.path.join(Config.PROXY_DIR, self.name) + '.conf'
        ngx_conf_content = r'''server {
    listen 80;
    server_name %s;
    index index.htm index.html index.php index.jsp;
    location / {
        proxy_pass http://%s:%s/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}''' % (self.dn, self.ip, int(self.port))
        with open(ngx_user_conf, 'w') as f:
            f.write(ngx_conf_content)
        from sh import nginx
        nginx('-s', 'reload')
예제 #5
0
 def stop(self):
     self.print("Stopping server")
     sh.nginx("-s", 'stop')
예제 #6
0
 def reload(self):
     self.print("Reloading server")
     sh.nginx("-s", 'reload')
예제 #7
0
 def start(self):
     self.print("Starting server")
     sh.nginx("-g", 'daemon off;')