コード例 #1
0
ファイル: info.py プロジェクト: dengine/easyengine
 def info_nginx(self):
     """Display Nginx information"""
     version = os.popen("nginx -v 2>&1 | cut -d':' -f2 | cut -d' ' -f2 | "
                        "cut -d'/' -f2 | tr -d '\n'").read()
     allow = os.popen("grep ^allow /etc/nginx/common/acl.conf | "
                      "cut -d' ' -f2 | cut -d';' -f1 | tr '\n' ' '").read()
     nc = NginxConfig()
     nc.loadf('/etc/nginx/nginx.conf')
     user = nc.get('user')[1]
     worker_processes = nc.get('worker_processes')[1]
     worker_connections = nc.get([('events',), 'worker_connections'])[1]
     keepalive_timeout = nc.get([('http',), 'keepalive_timeout'])[1]
     if os.path.isfile('/etc/nginx/conf.d/ee-nginx.conf'):
         nc.loadf('/etc/nginx/conf.d/ee-nginx.conf')
         fastcgi_read_timeout = nc.get('fastcgi_read_timeout')[1]
         client_max_body_size = nc.get('client_max_body_size')[1]
     else:
         fastcgi_read_timeout = nc.get([('http',),
                                       'fastcgi_read_timeout'])[1]
         client_max_body_size = nc.get([('http',),
                                       'client_max_body_size'])[1]
     data = dict(version=version, allow=allow, user=user,
                 worker_processes=worker_processes,
                 keepalive_timeout=keepalive_timeout,
                 worker_connections=worker_connections,
                 fastcgi_read_timeout=fastcgi_read_timeout,
                 client_max_body_size=client_max_body_size)
     self.app.render((data), 'info_nginx.mustache')
コード例 #2
0
ファイル: debug.py プロジェクト: Backenkoehler/easyengine
    def debug_php7(self):
        """Start/Stop PHP debug"""
        # PHP global debug start

        if (self.app.pargs.php7 == 'on' and not self.app.pargs.site_name):
            if (EEVariables.ee_platform_codename == 'wheezy' or EEVariables.ee_platform_codename == 'precise'):
                Log.error(self,"PHP 7.0 not supported.")
            if not (EEShellExec.cmd_exec(self, "sed -n \"/upstream php7"
                                               "{/,/}/p \" /etc/nginx/"
                                               "conf.d/upstream.conf "
                                               "| grep 9170")):

                Log.info(self, "Enabling PHP 7.0 debug")

                # Change upstream.conf
                nc = NginxConfig()
                nc.loadf('/etc/nginx/conf.d/upstream.conf')
                nc.set([('upstream','php',), 'server'], '127.0.0.1:9170')
                if os.path.isfile("/etc/nginx/common/wpfc-hhvm.conf"):
                    nc.set([('upstream','hhvm',), 'server'], '127.0.0.1:9170')
                nc.savef('/etc/nginx/conf.d/upstream.conf')

                # Enable xdebug
                if (EEVariables.ee_platform_codename != 'jessie'):
                    EEFileUtils.searchreplace(self, "/etc/php/7.0/mods-available/"
                                              "xdebug.ini",
                                              ";zend_extension",
                                              "zend_extension")
                else:
                    EEFileUtils.searchreplace(self, "/etc/php/mods-available/"
                                              "xdebug.ini",
                                              ";zend_extension",
                                              "zend_extension")

                # Fix slow log is not enabled default in PHP5.6
                config = configparser.ConfigParser()
                config.read('/etc/php/7.0/fpm/pool.d/debug.conf')
                config['debug']['slowlog'] = '/var/log/php/7.0/slow.log'
                config['debug']['request_slowlog_timeout'] = '10s'
                with open('/etc/php/7.0/fpm/pool.d/debug.conf',
                          encoding='utf-8', mode='w') as confifile:
                    Log.debug(self, "Writting debug.conf configuration into "
                              "/etc/php/7.0/fpm/pool.d/debug.conf")
                    config.write(confifile)

                self.trigger_php = True
                self.trigger_nginx = True
            else:
                Log.info(self, "PHP debug is already enabled")

            self.msg = self.msg + ['/var/log/php/7.0/slow.log']

        # PHP global debug stop
        elif (self.app.pargs.php7 == 'off' and not self.app.pargs.site_name):
            if EEShellExec.cmd_exec(self, " sed -n \"/upstream php {/,/}/p\" "
                                          "/etc/nginx/conf.d/upstream.conf "
                                          "| grep 9170"):
                Log.info(self, "Disabling PHP 7.0 debug")

                # Change upstream.conf
                nc = NginxConfig()
                nc.loadf('/etc/nginx/conf.d/upstream.conf')
                nc.set([('upstream','php',), 'server'], '127.0.0.1:9070')
                if os.path.isfile("/etc/nginx/common/wpfc-hhvm.conf"):
                    nc.set([('upstream','hhvm',), 'server'], '127.0.0.1:8000')
                nc.savef('/etc/nginx/conf.d/upstream.conf')

                # Disable xdebug
                if (EEVariables.ee_platform_codename != 'jessie'):
                    EEFileUtils.searchreplace(self, "/etc/php/7.0/mods-available/"
                                          "xdebug.ini",
                                          "zend_extension",
                                          ";zend_extension")
                else:
                    EEFileUtils.searchreplace(self, "/etc/php/mods-available/"
                                          "xdebug.ini",
                                          "zend_extension",
                                          ";zend_extension")

                self.trigger_php = True
                self.trigger_nginx = True
            else:
                Log.info(self, "PHP 7.0 debug is already disabled")
コード例 #3
0
    def debug_php(self):
        """Start/Stop PHP debug"""
        # PHP global debug start

        if (self.app.pargs.php == 'on' and not self.app.pargs.site_name):
            if not (WOShellExec.cmd_exec(
                    self, "sed -n \"/upstream php"
                    "{/,/}/p \" /etc/nginx/"
                    "conf.d/upstream.conf "
                    "| grep 9001")):

                Log.info(self, "Enabling PHP debug")

                # Change upstream.conf
                nc = NginxConfig()
                nc.loadf('/etc/nginx/conf.d/upstream.conf')
                nc.set([(
                    'upstream',
                    'php',
                ), 'server'], '127.0.0.1:9001')
                if os.path.isfile("/etc/nginx/common/wpfc-hhvm.conf"):
                    nc.set([(
                        'upstream',
                        'hhvm',
                    ), 'server'], '127.0.0.1:9001')
                nc.savef('/etc/nginx/conf.d/upstream.conf')

                # Enable xdebug
                WOFileUtils.searchreplace(
                    self, "/etc/{0}/mods-available/".format("php/7.2" if (
                        WOVariables.wo_platform_codename == 'trusty'
                        or WOVariables.wo_platform_codename == 'xenial'
                        or WOVariables.wo_platform_codename == 'bionic'
                    ) else "php5") + "xdebug.ini", ";zend_extension",
                    "zend_extension")

                # Fix slow log is not enabled default in PHP5.6
                config = configparser.ConfigParser()
                config.read(
                    '/etc/{0}/fpm/pool.d/debug.conf'.format("php/7.2" if (
                        WOVariables.wo_platform_codename == 'trusty'
                        or WOVariables.wo_platform_codename == 'xenial'
                        or WOVariables.wo_platform_codename == 'bionic'
                    ) else "php5"))
                config['debug']['slowlog'] = '/var/log/{0}/slow.log'.format(
                    "php/7.2" if (
                        WOVariables.wo_platform_codename == 'trusty'
                        or WOVariables.wo_platform_codename == 'xenial'
                        or WOVariables.wo_platform_codename == 'bionic'
                    ) else "php5")
                config['debug']['request_slowlog_timeout'] = '10s'
                with open(
                        '/etc/{0}/fpm/pool.d/debug.conf'.format("php/7.2" if (
                            WOVariables.wo_platform_codename == 'trusty'
                            or WOVariables.wo_platform_codename == 'xenial'
                            or WOVariables.wo_platform_codename == 'bionic'
                        ) else "php5"),
                        encoding='utf-8',
                        mode='w') as confifile:
                    Log.debug(
                        self, "Writting debug.conf configuration into "
                        "/etc/{0}/fpm/pool.d/debug.conf".format("php/7.2" if (
                            WOVariables.wo_platform_codename == 'trusty'
                            or WOVariables.wo_platform_codename == 'xenial'
                            or WOVariables.wo_platform_codename == 'bionic'
                        ) else "php5"))
                    config.write(confifile)

                self.trigger_php = True
                self.trigger_nginx = True
            else:
                Log.info(self, "PHP debug is already enabled")

            self.msg = self.msg + [
                '/var/log/{0}/slow.log'.format("php/7.2" if (
                    WOVariables.wo_platform_codename == 'trusty'
                    or WOVariables.wo_platform_codename == 'xenial' or
                    WOVariables.wo_platform_codename == 'bionic') else "php5")
            ]

        # PHP global debug stop
        elif (self.app.pargs.php == 'off' and not self.app.pargs.site_name):
            if WOShellExec.cmd_exec(
                    self, " sed -n \"/upstream php {/,/}/p\" "
                    "/etc/nginx/conf.d/upstream.conf "
                    "| grep 9001"):
                Log.info(self, "Disabling PHP debug")

                # Change upstream.conf
                nc = NginxConfig()
                nc.loadf('/etc/nginx/conf.d/upstream.conf')
                nc.set([(
                    'upstream',
                    'php',
                ), 'server'], '127.0.0.1:9000')
                if os.path.isfile("/etc/nginx/common/wpfc-hhvm.conf"):
                    nc.set([(
                        'upstream',
                        'hhvm',
                    ), 'server'], '127.0.0.1:8000')
                nc.savef('/etc/nginx/conf.d/upstream.conf')

                # Disable xdebug
                WOFileUtils.searchreplace(
                    self, "/etc/{0}/mods-available/".format("php/7.2" if (
                        WOVariables.wo_platform_codename == 'trusty'
                        or WOVariables.wo_platform_codename == 'xenial'
                        or WOVariables.wo_platform_codename == 'bionic'
                    ) else "php5") + "xdebug.ini", "zend_extension",
                    ";zend_extension")

                self.trigger_php = True
                self.trigger_nginx = True
            else:
                Log.info(self, "PHP debug is already disabled")
コード例 #4
0
ファイル: debug.py プロジェクト: quimica/easyengine
    def debug_php7(self):
        """Start/Stop PHP debug"""
        # PHP global debug start

        if (self.app.pargs.php7 == 'on' and not self.app.pargs.site_name):
            if (EEVariables.ee_platform_codename == 'wheezy'
                    or EEVariables.ee_platform_codename == 'precise'):
                Log.error(self, "PHP 7.2 not supported.")
            if not (EEShellExec.cmd_exec(
                    self, "sed -n \"/upstream php7"
                    "{/,/}/p \" /etc/nginx/"
                    "conf.d/upstream.conf "
                    "| grep 9170")):

                Log.info(self, "Enabling PHP 7.2 debug")

                # Change upstream.conf
                nc = NginxConfig()
                nc.loadf('/etc/nginx/conf.d/upstream.conf')
                nc.set([(
                    'upstream',
                    'php7',
                ), 'server'], '127.0.0.1:9170')
                if os.path.isfile("/etc/nginx/common/wpfc-hhvm.conf"):
                    nc.set([(
                        'upstream',
                        'hhvm',
                    ), 'server'], '127.0.0.1:9170')
                nc.savef('/etc/nginx/conf.d/upstream.conf')

                # Enable xdebug
                EEFileUtils.searchreplace(
                    self, "/etc/php/7.2/mods-available/"
                    "xdebug.ini", ";zend_extension", "zend_extension")

                # Fix slow log is not enabled default in PHP5.6
                config = configparser.ConfigParser()
                config.read('/etc/php/7.2/fpm/pool.d/debug.conf')
                config['debug']['slowlog'] = '/var/log/php/7.2/slow.log'
                config['debug']['request_slowlog_timeout'] = '10s'
                with open('/etc/php/7.2/fpm/pool.d/debug.conf',
                          encoding='utf-8',
                          mode='w') as confifile:
                    Log.debug(
                        self, "Writting debug.conf configuration into "
                        "/etc/php/7.2/fpm/pool.d/debug.conf")
                    config.write(confifile)

                self.trigger_php = True
                self.trigger_nginx = True
            else:
                Log.info(self, "PHP debug is already enabled")

            self.msg = self.msg + ['/var/log/php/7.2/slow.log']

        # PHP global debug stop
        elif (self.app.pargs.php7 == 'off' and not self.app.pargs.site_name):
            if EEShellExec.cmd_exec(
                    self, " sed -n \"/upstream php7 {/,/}/p\" "
                    "/etc/nginx/conf.d/upstream.conf "
                    "| grep 9170"):
                Log.info(self, "Disabling PHP 7.2 debug")

                # Change upstream.conf
                nc = NginxConfig()
                nc.loadf('/etc/nginx/conf.d/upstream.conf')
                nc.set([(
                    'upstream',
                    'php7',
                ), 'server'], '127.0.0.1:9070')
                if os.path.isfile("/etc/nginx/common/wpfc-hhvm.conf"):
                    nc.set([(
                        'upstream',
                        'hhvm',
                    ), 'server'], '127.0.0.1:8000')
                nc.savef('/etc/nginx/conf.d/upstream.conf')

                # Disable xdebug
                EEFileUtils.searchreplace(
                    self, "/etc/php/7.2/mods-available/"
                    "xdebug.ini", "zend_extension", ";zend_extension")

                self.trigger_php = True
                self.trigger_nginx = True
            else:
                Log.info(self, "PHP 7.2 debug is already disabled")
コード例 #5
0
ファイル: debug.py プロジェクト: zeus911/WordOps
    def debug_php73(self):
        """Start/Stop PHP debug"""
        # PHP global debug start

        if (self.app.pargs.php73 == 'on' and not self.app.pargs.site_name):
            if not (WOShellExec.cmd_exec(
                    self, "sed -n \"/upstream php73"
                    "{/,/}/p \" /etc/nginx/"
                    "conf.d/upstream.conf "
                    "| grep 9173")):

                Log.info(self, "Enabling PHP 7.3 debug")

                # Change upstream.conf
                nc = NginxConfig()
                nc.loadf('/etc/nginx/conf.d/upstream.conf')
                nc.set([(
                    'upstream',
                    'php73',
                ), 'server'], '127.0.0.1:9173')
                nc.savef('/etc/nginx/conf.d/upstream.conf')

                # Enable xdebug
                WOFileUtils.searchreplace(
                    self, "/etc/php/7.3/mods-available/"
                    "xdebug.ini", ";zend_extension", "zend_extension")

                # Fix slow log is not enabled default in PHP5.6
                config = configparser.ConfigParser()
                config.read('/etc/php/7.3/fpm/pool.d/debug.conf')
                config['debug']['slowlog'] = '/var/log/php/7.3/slow.log'
                config['debug']['request_slowlog_timeout'] = '10s'
                with open('/etc/php/7.3/fpm/pool.d/debug.conf',
                          encoding='utf-8',
                          mode='w') as confifile:
                    Log.debug(
                        self, "Writting debug.conf configuration into "
                        "/etc/php/7.3/fpm/pool.d/debug.conf")
                    config.write(confifile)

                self.trigger_php = True
                self.trigger_nginx = True
            else:
                Log.info(self, "PHP debug is already enabled")

            self.msg = self.msg + ['/var/log/php/7.3/slow.log']

        # PHP global debug stop
        elif (self.app.pargs.php73 == 'off' and not self.app.pargs.site_name):
            if WOShellExec.cmd_exec(
                    self, " sed -n \"/upstream "
                    "php73 {/,/}/p\" "
                    "/etc/nginx/conf.d/upstream.conf "
                    "| grep 9173"):
                Log.info(self, "Disabling PHP 7.3 debug")

                # Change upstream.conf
                nc = NginxConfig()
                nc.loadf('/etc/nginx/conf.d/upstream.conf')
                nc.set([(
                    'upstream',
                    'php73',
                ), 'server'], 'unix:/var/run/php/php73-fpm.sock')
                nc.savef('/etc/nginx/conf.d/upstream.conf')

                # Disable xdebug
                WOFileUtils.searchreplace(
                    self, "/etc/php/7.3/mods-available/"
                    "xdebug.ini", "zend_extension", ";zend_extension")

                self.trigger_php = True
                self.trigger_nginx = True
            else:
                Log.info(self, "PHP 7.3 debug is already disabled")