#NEWLINE# @ expose ( hide = True ) #NEWLINE# def default( self ) : #NEWLINE# #INDENT# 'Default function of log GZip' #NEWLINE# self . msg = [ ] #NEWLINE# if self . app . pargs . php : #NEWLINE# #INDENT# self . app . pargs . nginx = True #NEWLINE# #UNINDENT# if ( ( not self . app . pargs . nginx ) and ( not self . app . pargs . fpm ) and ( not self . app . pargs . mysql ) and ( not self . app . pargs . access ) and ( not self . app . pargs . wp ) and ( not self . app . pargs . site_name ) ) : #NEWLINE# #INDENT# self . app . pargs . nginx = True #NEWLINE# self . app . pargs . fpm = True #NEWLINE# self . app . pargs . mysql = True #NEWLINE# self . app . pargs . access = True #NEWLINE# #UNINDENT# if ( ( not self . app . pargs . nginx ) and ( not self . app . pargs . fpm ) and ( not self . app . pargs . mysql ) and ( not self . app . pargs . access ) and ( not self . app . pargs . wp ) and self . app . pargs . site_name ) : #NEWLINE# #INDENT# self . app . pargs . nginx = True #NEWLINE# self . app . pargs . wp = True #NEWLINE# self . app . pargs . access = True #NEWLINE# self . app . pargs . mysql = True #NEWLINE# #UNINDENT# if ( gzf . app . pargs . nginx and ( not self . app . pargs . site_name ) ) : #NEWLINE# #INDENT# self . msg = ( self . msg + [ '/var/log/nginx/*error.log' ] ) #NEWLINE# #UNINDENT# if ( self . app . pargs . access and ( not self . app . pargs . site_name ) ) : #NEWLINE# #INDENT# self . msg = ( self . msg + [ '/var/log/nginx/*access.log' ] ) #NEWLINE# #UNINDENT# if self . app . pargs . fpm : #NEWLINE# #INDENT# open ( '/var/log/php5/slow.log' , 'a' ) . close ( ) #NEWLINE# open ( '/var/log/php5/fpm.log' , 'a' ) . close ( ) #NEWLINE# self . msg = ( self . msg + [ '/var/log/php5/slow.log' , '/var/log/php5/fpm.log' ] ) #NEWLINE# #UNINDENT# if self . app . pargs . mysql : #NEWLINE# #INDENT# if ( EEVariables . ee_mysql_host is 'localhost' ) : #NEWLINE# #INDENT# if os . path . isfile ( '/var/log/mysql/mysql-slow.log' ) : #NEWLINE# #INDENT# self . msg = ( self . msg + [ '/var/log/mysql/mysql-slow.log' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# Log . info ( self , 'MySQL slow-log not found, skipped' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# Log . warn ( self , 'Remote MySQL found, EasyEngine is not able toshow MySQL log file' ) #NEWLINE# #UNINDENT# #UNINDENT# if self . app . pargs . site_name : #NEWLINE# #INDENT# webroot = '{0}{1}' . format ( EEVariables . ee_webroot , self . app . pargs . site_name ) #NEWLINE# if ( not os . path . isdir ( webroot ) ) : #NEWLINE# #INDENT# Log . error ( self , 'Site not present, quitting' ) #NEWLINE# #UNINDENT# if self . app . pargs . access : #NEWLINE# #INDENT# self . msg = ( self . msg + [ '{0}/{1}/logs/access.log' . format ( EEVariables . ee_webroot , self . app . pargs . site_name ) ] ) #NEWLINE# #UNINDENT# if self . app . pargs . nginx : #NEWLINE# #INDENT# self . msg = ( self . msg + [ '{0}/{1}/logs/error.log' . format ( EEVariables . ee_webroot , self . app . pargs . site_name ) ] ) #NEWLINE# #UNINDENT# if self . app . pargs . wp : #NEWLINE# #INDENT# if os . path . isdir ( '{0}/htdocs/wp-content' . format ( webroot ) ) : #NEWLINE# #INDENT# if ( not os . path . isfile ( '{0}/logs/debug.log' . format ( webroot ) ) ) : #NEWLINE# #INDENT# if ( not os . path . isfile ( '{0}/htdocs/wp-content/debug.log' . format ( webroot ) ) ) : #NEWLINE# #INDENT# open ( '{0}/htdocs/wp-content/debug.log' . format ( webroot ) , encoding = 'utf-8' , mode = 'a' ) . close ( ) #NEWLINE# EEShellExec . cmd_exec ( self , 'chown {1}: {0}/htdocs/wp-content/debug.log' . format ( webroot , EEVariables . ee_php_user ) ) #NEWLINE# #UNINDENT# #UNINDENT# EEFileUtils . create_symlink ( self , [ '{0}/htdocs/wp-content/debug.log' . format ( webroot ) , '{0}/logs/debug.log' . format ( webroot ) ] ) #NEWLINE# self . msg = ( self . msg + [ '{0}/{1}/logs/debug.log' . format ( EEVariables . ee_webroot , self . app . pargs . site_name ) ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# Log . info ( self , 'Site is not WordPress site, skipping WordPress logs' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# gzip_list = [ ] #NEWLINE# for g_list in self . msg : #NEWLINE# #INDENT# gzip_list = ( gzip_list + glob . glob ( g_list ) ) #NEWLINE# #UNINDENT# for g_list in gzip_list : #NEWLINE# #INDENT# Log . info ( self , 'Gzipping file {file}' . format ( file = g_list ) ) #NEWLINE# in_file = g_list #NEWLINE# in_data = open ( in_file , 'rb' ) . read ( ) #NEWLINE# out_gz = ( g_list + '.gz' ) #NEWLINE# gzf = gzip . open ( out_gz , 'wb' ) #NEWLINE# gzf . write ( in_data ) #NEWLINE# gzf . close ( )