Ejemplo n.º 1
0
            # reload cached arp table contents
            bgprocess.arp.reload()

            # update accounting info, for all zones
            bgprocess.db.update_accounting_info(bgprocess.ipfw.list_accounting_info())

            # process sessions per zone
            for zoneid in bgprocess.list_zone_ids():
                bgprocess.sync_zone(zoneid)

            # close the database handle while waiting for the next poll
            bgprocess.db.close()

            # sleep
            time.sleep(5)
        except KeyboardInterrupt:
            break
        except SystemExit:
            break
        except:
            syslog.syslog(syslog.LOG_ERR, traceback.format_exc())
            print(traceback.format_exc())
            break

# startup
if len(sys.argv) > 1 and sys.argv[1].strip().lower() == 'run':
    main()
else:
    daemon = Daemonize(app=__file__.split('/')[-1].split('.py')[0], pid='/var/run/captiveportal.db.pid', action=main)
    daemon.start()
Ejemplo n.º 2
0
            for zoneid in bgprocess.list_zone_ids():
                bgprocess.sync_zone(zoneid)

            # close the database handle while waiting for the next poll
            bgprocess.db.close()

            # process accounting messages (uses php script, for reuse of Auth classes)
            try:
                subprocess.call(['/usr/local/opnsense/scripts/OPNsense/CaptivePortal/process_accounting_messages.php'])
            except OSError:
                # if accounting script crashes don't exit backgroung process
                pass

            # sleep
            time.sleep(5)
        except KeyboardInterrupt:
            break
        except SystemExit:
            break
        except:
            syslog.syslog(syslog.LOG_ERR, traceback.format_exc())
            print(traceback.format_exc())
            break

# startup
if len(sys.argv) > 1 and sys.argv[1].strip().lower() == 'run':
    main()
else:
    daemon = Daemonize(app=__file__.split('/')[-1].split('.py')[0], pid='/var/run/captiveportal.db.pid', action=main)
    daemon.start()
Ejemplo n.º 3
0
from config import Config
from lib import ActionsManager
from lib.daemonize import Daemonize
from lib import CMD
from lib import Logger
import os

PID_FILE = os.path.join(os.getcwd(),'process.pid')

def main():
    Logger().log('enter main function')
    actions = Config.actions
    for actionName  in actions:
        ActionsManager().regiest(actionName,actions[actionName])
    ActionsManager().run()

if __name__ == '__main__':
    daemon = Daemonize(app='ProcessDaemon',pid=PID_FILE,action=main)
    if CMD == 'start':
        Logger().log('start daemon')
        daemon.start()
    elif CMD == 'stop':
        Logger().log('stop daemon')
        daemon.exit()
    else:
        print """ProcessDaemon:
        useage: python entry.py -c start -r production
            -c --command start stop : start or stop process daemon
            -r --runmode develop testing production : set run mode
        """
Ejemplo n.º 4
0
from lib.daemonize import Daemonize
from lib import CMD
from lib import Logger
import os

PID_FILE = os.path.join(os.getcwd(), 'process.pid')


def main():
    Logger().log('enter main function')
    actions = Config.actions
    for actionName in actions:
        ActionsManager().regiest(actionName, actions[actionName])
    ActionsManager().run()


if __name__ == '__main__':
    daemon = Daemonize(app='ProcessDaemon', pid=PID_FILE, action=main)
    if CMD == 'start':
        Logger().log('start daemon')
        daemon.start()
    elif CMD == 'stop':
        Logger().log('stop daemon')
        daemon.exit()
    else:
        print """ProcessDaemon:
        useage: python entry.py -c start -r production
            -c --command start stop : start or stop process daemon
            -r --runmode develop testing production : set run mode
        """