コード例 #1
0
    def terminate(self):
        kill_cmd = "kill -9 %s" % self.get_pid()

        if os.path.isfile(self.__pid_path):
            servo.run_as_sudo(kill_cmd)

        if self.check_haproxy_process() == 0:
            raise ServoError("haproxy still running")
        self.__status = HaproxyProcess.TERMINATED
コード例 #2
0
    def terminate(self):
        kill_cmd = 'kill -9 %s' % self.get_pid()

        if os.path.isfile(self.__pid_path):
            servo.run_as_sudo(kill_cmd)

        if self.check_haproxy_process() == 0:
            raise ServoError("haproxy still running")
        self.__status = HaproxyProcess.TERMINATED
コード例 #3
0
    def terminate(self):
        pids = self.get_pids()

        for pid in pids:
            kill_cmd = 'kill -9 %s' % pid
            servo.run_as_sudo(kill_cmd)

        if self.check_haproxy_process() == 0:
            raise ServoError("haproxy still running")

        self.__status = HaproxyProcess.TERMINATED
コード例 #4
0
 def unmount_floppy(self, dir=config.FLOPPY_MOUNT_DIR):
     if not os.path.exists(dir):
         return
     if servo.run_as_sudo('/bin/umount %s' % dir) == 0:
         servo.log.debug('floppy disk unmounted on ' + dir)
     else:
         raise Exception('failed to unmount floppy')
コード例 #5
0
 def mount_floppy(self, dev='/dev/fd0', dir=config.FLOPPY_MOUNT_DIR):
     if not os.path.exists(dir):
         os.makedirs(dir)
     if servo.run_as_sudo('/bin/mount %s %s' % (dev, dir)) == 0:
         servo.log.debug('floppy disk mounted on ' + dir)
     else:
         raise Exception('failed to mount floppy')
コード例 #6
0
 def unmount_floppy(self, dir=config.FLOPPY_MOUNT_DIR):
     if not os.path.exists(dir):
         return
     if servo.run_as_sudo('/bin/umount %s' % dir) == 0:
         servo.log.debug('floppy disk unmounted on ' + dir)
     else:
         raise Exception('failed to unmount floppy')
コード例 #7
0
 def mount_floppy(self, dev='/dev/fd0', dir=config.FLOPPY_MOUNT_DIR):
     if not os.path.exists(dir):
         os.makedirs(dir)
     if servo.run_as_sudo('/bin/mount -o uid=%d %s %s' %
                          (os.geteuid(), dev, dir)) == 0:
         servo.log.debug('floppy disk mounted on ' + dir)
     else:
         raise Exception('failed to mount floppy')
コード例 #8
0
    def run(self):
        # make sure no other haproxy process running
        if self.__status == HaproxyProcess.RUNNING or self.check_haproxy_process() == 0:
            raise ServoError("haproxy already running")

        haproxy_cmd = "%s -f %s -p %s -V -C %s -D" % (self.__haproxy_bin, self.__conf_file, self.__pid_path, RUN_ROOT)

        if servo.run_as_sudo(haproxy_cmd) != 0:
            raise ServoError("failed to launch haproxy process")

        self.__status = HaproxyProcess.RUNNING
コード例 #9
0
    def restart(self):
        if self.check_haproxy_process() != 0:
            servo.log.warning('on restart, no running haproxy process found')

        haproxy_cmd = '%s -f %s -p %s -V -C %s -D -sf %s)' % (
            self.__haproxy_bin, self.__conf_file, self.__pid_path, RUN_ROOT,
            self.get_pid())

        if servo.run_as_sudo(haproxy_cmd) != 0:
            raise ServoError("failed to restart haproxy process")

        self.__status = HaproxyProcess.RUNNING
コード例 #10
0
    def run(self):
        # make sure no other haproxy process running
        if self.__status == HaproxyProcess.RUNNING or self.check_haproxy_process(
        ) == 0:
            raise ServoError("haproxy already running")

        haproxy_cmd = '%s -f %s -p %s -V -C %s -D' % (
            self.__haproxy_bin, self.__conf_file, self.__pid_path, RUN_ROOT)

        if servo.run_as_sudo(haproxy_cmd) != 0:
            raise ServoError("failed to launch haproxy process")

        self.__status = HaproxyProcess.RUNNING
コード例 #11
0
    def restart(self):
        if self.check_haproxy_process() != 0:
            servo.log.warning("on restart, no running haproxy process found")

        haproxy_cmd = "%s -f %s -p %s -V -C %s -D -sf %s)" % (
            self.__haproxy_bin,
            self.__conf_file,
            self.__pid_path,
            RUN_ROOT,
            self.get_pid(),
        )

        if servo.run_as_sudo(haproxy_cmd) != 0:
            raise ServoError("failed to restart haproxy process")

        self.__status = HaproxyProcess.RUNNING