def status(self): out, err = exec("sudo pgrep -lf nginx") # print(out, err) if len(out) == 0: return STATUS_NOT_RUNNING for l in out: if "{}/etc/nginx/nginx.conf".format(SERVER_ROOT) in l: return STATUS_OK return STATUS_BAD_RUNNING
def status(self): o, _ = exec('sudo brew services list') for l in o: if 'mysql' in l: if 'started' in l: return STATUS_OK else: return STATUS_NOT_RUNNING return STATUS_NOT_RUNNING
def status(self): out, err = exec("sudo pgrep -lf php-fpm") ok_line = "php-fpm -y {}/etc/php/7.0/php-fpm.conf -c {}/etc/php/7.0/php.ini".format(SERVER_ROOT,SERVER_ROOT) if len(out) == 0: return STATUS_NOT_RUNNING for l in out: if ok_line in l: return STATUS_OK return STATUS_BAD_RUNNING
def check_installs(): if not os.geteuid() == 0: print( "need sudo to run this script, please, rerun with:\nsudo python3 {}" .format(sys.argv[0])) sys.exit(1) checks, _ = exec("which brew".format(USER)) if len(checks) == 0: print( 'Can not proceed without brew, visit https://brew.sh/ to install brew' ) sys.exit(2) checks, _ = exec("sudo -u {} brew list".format(USER)) if 'nginx' not in checks: print('Can not proceed without nginx, run:\nbrew install nginx') sys.exit(3) if 'php70' not in checks: print('Can not proceed without php70, run:\nbrew install php70') sys.exit(3)
def start(self): nginx_start_cmd = "sudo nginx -c {}/etc/nginx/nginx.conf".format(SERVER_ROOT) self.append_etc_hosts() exec(nginx_start_cmd)
def stop(self): exec('sudo nginx -s stop; sudo killall nginx')
def get_is_installed(self): out, _ = exec('readlink `which apachectl`')
def stop(self): exec("sudo apachectl stop")
def start(self): exec("sudo apachectl start -f /usr/local/apache2/conf/httpd.conf")
def status(self): status, _= exec('sudo pgrep -lf apache2') for l in status: if 'httpd -k start' in l: return STATUS_OK
def stop(self): exec('sudo brew services stop mysql')
def start(self): exec('sudo brew services start mysql')
def stop(self): exec('sudo killall php-fpm')
def start(self): php_70_start_command = "sudo /usr/local/opt/php70/sbin/php-fpm -y {}/etc/php/7.0/php-fpm.conf -c {}/etc/php/7.0/php.ini".format(SERVER_ROOT, SERVER_ROOT) exec(php_70_start_command)
import os from helpers import exec ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) HOME = exec("cd ~ && pwd")[0][0] USER = HOME.split('/')[-1] SERVER_ROOT = "{}/web".format(HOME)