示例#1
0
def detect_apps(srv_dir, dry_run=False):
    dirs = os.listdir(srv_dir)
    os.chdir(srv_dir)
    for d in dirs:
        # Check if domain is active (DNS check)
        try:
            ip = socket.gethostbyname(d)
        except socket.gaierror:
            logging.warning("Wrong directory name: %s" % d)
            continue

        if "uwsgi.ini" in os.listdir(d):
            # We've found uWSGI app!
            # Now create nginx vhost based on dir name
            if dry_run:
                logging.info("uWSGI app found in %s" % d)
            else:
                app_dir = "%s/%s" % (srv_dir, d)
                if nginx.vhost_exists(d):
                    logging.info("Virtualhost %s already exists on nginx" % d)
                    continue
                nginx.add_uwsgi_vhost(
                        domain_name=d,
                        document_root=app_dir
                        )
                # Enable supervisord for uWSGI process
                supervisord.new_app(app_name=d, app_dir=app_dir)
                nginx.enable_vhost(d)
                logging.info("Added new app: %s" % d)
示例#2
0
def add_vhost(domain_name, document_root, vhost_type):
    if vhost_type == 'php':
        nginx.add_proxy_vhost(domain_name)
        nginx.enable_vhost(domain_name)
        apache.add_php_vhost(domain_name, document_root)
        apache.enable_vhost(domain_name)
    elif vhost_type == 'uwsgi':
        nginx.add_uwsgi_vhost(domain_name, document_root)
        nginx.enable_vhost(domain_name)