Add foreground running.

master
q3k 2013-04-08 15:47:36 +02:00
parent c4ad992c50
commit 7cbe3329fe
2 changed files with 28 additions and 25 deletions

View File

@ -16,6 +16,7 @@ def _get_process_list():
def _start_pppd():
print " ".join(config.PPPD)
p = subprocess.Popen(config.PPPD, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
if p.returncode != 0:
@ -27,7 +28,7 @@ def _start_pppd():
def _get_pppd_pid():
for process, pid in _get_process_list():
for pid, process in _get_process_list():
if process.startswith("pppd"):
return pid

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python2
import os
import time
import sys
import argparse
@ -67,10 +66,13 @@ def doublefork(pidfile, logfile):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Make sure the ADSL network is up and display info on the FWA fron panel.")
parser.add_argument("--pidfile", default="/var/run/adsl-bouncer.pid", help="Path of file to write dameon PID to.")
parser.add_argument("--logfile", default="/var/log/adsl-bouncer.log", help="Path of log file.")
parser.add_argument("--daemonize", default="true", help="Whether we should daemonize the bouncer.")
parser.add_argument("--pidfile", default="/var/run/adsl-bouncer.pid", help="When daemonized, the path of file to write dameon PID to.")
parser.add_argument("--logfile", default="/var/log/adsl-bouncer.log", help="When daemonized, the path of log file.")
args = parser.parse_args()
daemonize = True if args.daemonize.lower() in ["true", "t", "yes", "y"] else False
if daemonize:
# see if daemon is already running
if os.path.exists(args.pidfile):
with open(args.pidfile, "r") as f: