예제 #1
0
파일: dwg.py 프로젝트: cofind/smsServer
def main():
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.bind(('', dwgconfig.port))
    sock.listen(1)
    logger('[SYSTEM] Server listening...', False)

    try:
        while True:
            conn, addr = sock.accept()
            logger('[SYSTEM] Gateway connected %s' % addr[0], False)
            DWGD(conn)
            logger('[SYSTEM] Gateway disconnected', False)
    except KeyboardInterrupt:
        exit()
    finally:
        sock.close()
예제 #2
0
def main():
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.bind(('', dwgconfig.port))
    sock.listen(1)
    logger('[SYSTEM] Server listening...', False)

    try:
        while True:
            conn, addr = sock.accept()
            logger('[SYSTEM] Gateway connected %s' % addr[0], False)
            DWGD(conn)
            logger('[SYSTEM] Gateway disconnected', False)
    except KeyboardInterrupt:
        exit()
    finally:
        sock.close()
예제 #3
0
파일: dwg.py 프로젝트: cofind/smsServer
"""

class DWGDaemon(Daemon):
    def run(self):
        main()

"""
Check agrvs
"""
if __name__ == "__main__":
    daemon = DWGDaemon(dwgconfig.pidfile)
    if len(argv) == 2:
        if argv[1] == 'debug':
            dwgconfig.debug = True
            dwgconfig.as_daemon = False
            logger('[SYSTEM] Debug mode is on', True)
            main()
        elif argv[1] == 'start':
            logger('[SYSTEM] Daemon started', True)
            daemon.start()
        elif argv[1] == 'stop':
            logger('[SYSTEM] Daemon stopped', True)
            daemon.stop()
        elif argv[1] == 'restart':
            logger('[SYSTEM] Daemon restarted', True)
            daemon.restart()
        else:
            usage()
            exit(2)
        exit(0)
    else:
예제 #4
0
class DWGDaemon(Daemon):
    def run(self):
        main()


"""
Check agrvs
"""
if __name__ == "__main__":
    daemon = DWGDaemon(dwgconfig.pidfile)
    if len(argv) == 2:
        if argv[1] == 'debug':
            dwgconfig.debug = True
            dwgconfig.as_daemon = False
            logger('[SYSTEM] Debug mode is on', True)
            main()
        elif argv[1] == 'start':
            logger('[SYSTEM] Daemon started', True)
            daemon.start()
        elif argv[1] == 'stop':
            logger('[SYSTEM] Daemon stopped', True)
            daemon.stop()
        elif argv[1] == 'restart':
            logger('[SYSTEM] Daemon restarted', True)
            daemon.restart()
        else:
            usage()
            exit(2)
        exit(0)
    else: