webserver.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:djangoeurope-fabfile 作者: wservices 项目源码 文件源码
def install_nginx(*args, **kwargs):
    home = run('echo $HOME')
    nginx_dir = os.path.join(home, 'nginx')
    nginx_port = kwargs.get('port')

    run('mkdir -p %s/conf/sites' % nginx_dir)
    if not exists('%s/conf/nginx.conf' % nginx_dir):
        run('wget https://templates.wservices.ch/nginx/nginx.conf -O %s' % (os.path.join(nginx_dir, 'conf', 'nginx.conf')))
    run('mkdir -p %s/temp' % nginx_dir)
    run('mkdir -p %s/logs' % nginx_dir)

    # save the port number in a separete file in ~/nginx/conf/port
    # This port will be automatically used for future installations
    if nginx_port and not exists(os.path.join(nginx_dir, 'conf', 'port')):
        append(os.path.join(os.path.join(nginx_dir, 'conf', 'port')), str(nginx_port))

    run('mkdir -p ~/init')
    if not exists('~/init/nginx'):
        run('wget https://templates.wservices.ch/nginx/init -O ~/init/nginx')
        run('chmod 750 ~/init/nginx')

    if exists('~/nginx/nginx.pid'):
        run('~/init/nginx restart')
    else:
        run('~/init/nginx start')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号