ServerDjangoUwsgi.py 文件源码

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

项目:ezhost 作者: zhexiao 项目源码 文件源码
def install_supervisor(self):
        if self.args.force or prompt(red(' * Install Supervisor controller for Uwsgi (y/n)?'), default='y') == 'y':
            sudo('apt-get install supervisor -y')

            # supervisor config string
            supervisor_uwsgi_ini = self.supervisor_uwsgi_ini.format(self.project, self.project_dir)

            # create supervisor control configruation
            with cd(self.supervisor_config_dir):
                if not exists('{0}_sysd.conf'.format(self.project)):
                    sudo('touch {0}_sysd.conf'.format(self.project))

                # supervisor control uwsgi config
                put(StringIO(supervisor_uwsgi_ini), '{0}_sysd.conf'.format(self.project), use_sudo=True)

            # create supervisor log and error file
            with cd('/var/log'):
                if not exists('{0}_out.log'.format(self.project)):
                    sudo('touch {0}_out.log'.format(self.project))

                if not exists('{0}_error.log'.format(self.project)):
                    sudo('touch {0}_error.log'.format(self.project))

            # enable and start supervisor
            try:
                # ubuntu 16
                sudo('systemctl enable supervisor')
                sudo('systemctl start supervisor')
            except:
                # ubuntu 14
                sudo('supervisorctl reread')
                sudo('supervisorctl update')
                sudo('update-rc.d supervisor enable')

            print(green(' * Installed Supervisor controller in the system.'))
            print(green(' * Done '))
            print()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号