import sys, socket import struct import time import lydef, lylog, lyconf, lyauth, lyutil LY_OSM_KEEPALIVE_INTVL = 10 LY_OSM_KEEPALIVE_PROBES = 3 LOG = lylog.logger() def getclcparm(): mcast_ip = lyconf.Config.clc_mcast_ip mcast_port = lyconf.Config.clc_mcast_port sock = None try: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind(('', mcast_port)) mreq = struct.pack("4sl", socket.inet_aton(mcast_ip), socket.INADDR_ANY) sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq) sock.settimeout(15.0) except socket.error, (value, message): LOG.warn(message) if sock: sock.close() return 1
#!/usr/bin/python import os, getopt, sys, time, signal, shutil import lylog, lyconf, lyip import lyutil, lyconn, lyproc, lyapp PROGRAM_NAME = b"lyosm.py" PROGRAM_VERSION = b"0.4.0" # DEFAULT_OSM_CONF_PATH = b'C:\LuoYun\conf\luoyun.conf' DEFAULT_OSM_CONF_PATH = b"A:\luoyun.ini" DEFAULT_OSM_LOG_PATH = b"C:\LuoYun\log\luoyun.log" DEFAULT_OSM_SCRIPT_DIR = b"C:\LuoYun\scripts" LOG = lylog.logger() progrun = 1 osmsock = None def myexit(sig, func=None): global progrun progrun = 0 if sig == signal.SIGTERM: LOG.info("TERM signal captured") elif sig == signal.SIGINT: LOG.info("INTERUPT signal captured") else: LOG.info("unknown signal captured") if osmsock: osmsock.close() sys.exit(0)