Daemonic check-in/out.
This commit is contained in:
parent
9d0b48da9a
commit
7eacfa14f8
|
@ -193,7 +193,7 @@ class Operator(wd.Firefox):
|
||||||
user_form.send_keys(user)
|
user_form.send_keys(user)
|
||||||
pass_form.send_keys(password)
|
pass_form.send_keys(password)
|
||||||
do_it = True
|
do_it = True
|
||||||
if self.debug and not force and self.opts.headless:
|
if self.debug and not force and not self.opts.headless:
|
||||||
_do_it = input("Really do the login? [y/n] ").lower()
|
_do_it = input("Really do the login? [y/n] ").lower()
|
||||||
do_it = True if _do_it == "y" else False
|
do_it = True if _do_it == "y" else False
|
||||||
if do_it:
|
if do_it:
|
||||||
|
|
|
@ -112,7 +112,7 @@ def operator_login(op: Operator, username: str, password: str, force: bool) -> N
|
||||||
"""
|
"""
|
||||||
Instructs the operator to perform login.
|
Instructs the operator to perform login.
|
||||||
"""
|
"""
|
||||||
logger.debug("Performing login.")
|
logger.debug("Performing login...")
|
||||||
op.login(username, password, force)
|
op.login(username, password, force)
|
||||||
logger.info("Login done.")
|
logger.info("Login done.")
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ def operator_logout(op: Operator, force: bool) -> None:
|
||||||
"""
|
"""
|
||||||
Instructs the operator to perform logout.
|
Instructs the operator to perform logout.
|
||||||
"""
|
"""
|
||||||
logger.debug("Performing logout.")
|
logger.debug("Performing logout...")
|
||||||
op.logout(force)
|
op.logout(force)
|
||||||
logger.info("Logout done.")
|
logger.info("Logout done.")
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ def operator_checkin(op: Operator, force: bool) -> None:
|
||||||
Instructs the operator to perform the check in.
|
Instructs the operator to perform the check in.
|
||||||
"""
|
"""
|
||||||
logger.debug("Performing check in...")
|
logger.debug("Performing check in...")
|
||||||
op.checkin()
|
op.check_in(force)
|
||||||
logger.info("Check in done.")
|
logger.info("Check in done.")
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ def operator_checkout(op: Operator, force: bool) -> None:
|
||||||
Instructs the operator to perform the check out.
|
Instructs the operator to perform the check out.
|
||||||
"""
|
"""
|
||||||
logger.debug("Performing check out...")
|
logger.debug("Performing check out...")
|
||||||
op.checkout()
|
op.check_out(force)
|
||||||
logger.info("Check out done.")
|
logger.info("Check out done.")
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,24 +175,34 @@ def daemon_process(
|
||||||
debug=debug,
|
debug=debug,
|
||||||
)
|
)
|
||||||
|
|
||||||
def stop_all() -> None:
|
def _stop_all() -> None:
|
||||||
pass
|
logger.debug("SIGTERM...stopping all the clients...")
|
||||||
|
clients = PLifo.All(lifo_path)
|
||||||
|
with Fifo(fifo_path) as fifo:
|
||||||
|
for client in clients:
|
||||||
|
fifo.write(cmd_marshal(name=client, cmd="stop"))
|
||||||
|
|
||||||
def reload_all() -> None:
|
def _reload_all() -> None:
|
||||||
pass
|
logger.debug("SIGUSR1 received here.")
|
||||||
|
clients = PLifo.All(lifo_path)
|
||||||
|
with Fifo(fifo_path) as fifo:
|
||||||
|
for client in clients:
|
||||||
|
fifo.write(cmd_marshal(name=client, cmd="reload"))
|
||||||
|
|
||||||
def list_all() -> None:
|
def _list_all() -> None:
|
||||||
pass
|
logger.debug("SIGUSR2 received here.")
|
||||||
|
clients = PLifo.All(lifo_path)
|
||||||
|
logger.info("Client list: %s", clients)
|
||||||
|
|
||||||
context = daemon.DaemonContext(
|
context = daemon.DaemonContext(
|
||||||
working_directory=working_dir, umask=umask, pidfile=pidfile
|
working_directory=working_dir, umask=umask, pidfile=pidfile
|
||||||
)
|
)
|
||||||
logger.debug("context defined")
|
logger.debug("context defined")
|
||||||
context.signal_map = {
|
context.signal_map = {
|
||||||
signal.SIGTERM: stop_all,
|
signal.SIGTERM: _stop_all,
|
||||||
signal.SIGHUP: "terminate",
|
signal.SIGHUP: "terminate",
|
||||||
signal.SIGUSR1: reload_all,
|
signal.SIGUSR1: _reload_all,
|
||||||
signal.SIGUSR2: list_all,
|
signal.SIGUSR2: _list_all,
|
||||||
}
|
}
|
||||||
logger.debug("signal map defined")
|
logger.debug("signal map defined")
|
||||||
cmd_map = {
|
cmd_map = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user