Tidy worker codes

This commit is contained in:
zhuyj17 2018-05-27 17:09:09 +08:00
parent 9fb63fb475
commit 9b8a9a7135
5 changed files with 13 additions and 13 deletions

View File

@ -32,7 +32,6 @@ def initlogging(name='docklet'):
LOG_LEVEL = logging.CRITIAL
else:
LOG_LEVEL = logging.DEBUG
logger = logging.getLogger(name)
# Configure logging to log to a file, making a new file at midnight and keeping the last 3 day's data
# Give the logger a unique name (good practice)
@ -47,7 +46,6 @@ def initlogging(name='docklet'):
handler.setFormatter(formatter)
# Attach the handler to the logger
logger.addHandler(handler)
# Replace stdout with logging to file at INFO level
sys.stdout = RedirectLogger(logger, logging.INFO)
# Replace stderr with logging to file at ERROR level

View File

@ -34,7 +34,7 @@ import os, json
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
from itsdangerous import SignatureExpired, BadSignature
import env
from com import env
fsdir = env.getenv('FS_PREFIX')

View File

@ -1,9 +1,9 @@
#!/usr/bin/python3
import json, sys, netifaces, threading
from nettools import netcontrol,ovscontrol
from com.nettools import netcontrol,ovscontrol
from log import logger
from com.log import logger
# getip : get ip from network interface
# ifname : name of network interface

View File

@ -17,18 +17,17 @@ Design:Monitor mainly consists of three parts: Collectors, Master_Collector and
'''
import subprocess,re,os,etcdlib,psutil,math,sys
import subprocess,re,os,psutil,math,sys
import time,threading,json,traceback,platform
import env
from com import env, etcdlib
import lxc
import xmlrpc.client
from datetime import datetime
from model import db,VNode,History,BillingHistory,VCluster,PortMapping
from log import logger
from com.model import db,VNode,History,BillingHistory,VCluster,PortMapping
from com.log import logger
from httplib2 import Http
from urllib.parse import urlencode
from httprest import post_to_user
# billing parameters
a_cpu = 500 # seconds

View File

@ -2,14 +2,16 @@
# first init env
import sys
sys.path.append("../")
if sys.path[0].endswith("worker"):
sys.path[0] = sys.path[0][:-6]
from com import env, tools
config = env.getenv("CONFIG")
#tools.loadenv(config)
#config = "/opt/docklet/local/docklet-running.conf"
tools.loadenv(config)
# must import logger after initlogging, ugly
from com.log import initlogging
#initlogging("docklet-worker")
initlogging("docklet-worker")
from com.log import logger
import xmlrpc.server, sys, time
@ -19,6 +21,7 @@ from com import etcdlib, proxytool
from worker import container, monitor
from com.nettools import netcontrol,ovscontrol,portcontrol
from worker.lvmtool import new_group, recover_group
from master import network
##################################################################
# Worker