from threading import Thread
from multiprocessing import Process
import time
from config import LOGGER_SERVER_PORT, LOGGER_LOG_DIRECTORY, LOGGER_MAX_CONNECTION_REQUESTS
from utils.logging_helper import config_logger

STOP_TRIGGER_FILENAME = boinc_project_path.project_path('stop_daemons')

# A list of all child processes (entries added whenever a client connects and removed on disconnect)
child_list = list()

# Set to true when a SIGINT OR SIGHUP is caught
caught_sig_int = False

# Local logger for server logs
server_log = config_logger('ServerLog')
handler = logging.FileHandler('ServerLog.log')
formatter = logging.Formatter('%(asctime)-15s:' + logging.BASIC_FORMAT)
handler.setFormatter(formatter)
server_log.addHandler(handler)


def main():
    """
    Main program.
    1.Gets command line arguments and changes local_port or log_directory to match arguments.
      If no arguments are given, the defaults defined in config are used.
    2.Create log directory if it does not exist
    3.Set up socket to listen on specified port
    loop
        4.When connection is received, create new process to handle client
Esempio n. 2
0
import sys

# Setup the Python Path as we may be running this via ssh
base_path = os.path.dirname(__file__)
sys.path.append(os.path.abspath(os.path.join(base_path, '..')))
sys.path.append(os.path.abspath(os.path.join(base_path, '../../../../boinc/py')))

import argparse
from utils.logging_helper import config_logger, add_file_handler_to_root
from utils.s3_helper import S3Helper
from archive.archive_boinc_stats_mod import process_ami, process_boinc
from utils.ec2_helper import EC2Helper
from utils.name_builder import get_archive_bucket, get_log_archive_key, get_ami_log_file
from utils.sanity_checks import pass_sanity_checks

LOG = config_logger(__name__)

parser = argparse.ArgumentParser('Archive BOINC statistics to S3')
parser.add_argument('option', choices=['boinc','ami'], help='are we running on the BOINC server or the AMI server')
args = vars(parser.parse_args())

if args['option'] == 'boinc':
    LOG.info('PYTHONPATH = {0}'.format(sys.path))
    # We're running from the BOINC server
    process_boinc()
else:
    # We're running from a specially created AMI
    filename, full_filename = get_ami_log_file('archive_boinc_stats')
    add_file_handler_to_root(full_filename)
    LOG.info('PYTHONPATH = {0}'.format(sys.path))
    LOG.info('About to perform sanity checks')
Esempio n. 3
0
from threading import Thread
from multiprocessing import Process
import time
from config import LOGGER_SERVER_PORT, LOGGER_LOG_DIRECTORY, LOGGER_MAX_CONNECTION_REQUESTS
from utils.logging_helper import config_logger

STOP_TRIGGER_FILENAME = boinc_project_path.project_path('stop_daemons')

# A list of all child processes (entries added whenever a client connects and removed on disconnect)
child_list = list()

# Set to true when a SIGINT OR SIGHUP is caught
caught_sig_int = False

# Local logger for server logs
server_log = config_logger('ServerLog')
handler = logging.FileHandler('ServerLog.log')
formatter = logging.Formatter('%(asctime)-15s:' + logging.BASIC_FORMAT)
handler.setFormatter(formatter)
server_log.addHandler(handler)


def main():
    """
    Main program.
    1.Gets command line arguments and changes local_port or log_directory to match arguments.
      If no arguments are given, the defaults defined in config are used.
    2.Create log directory if it does not exist
    3.Set up socket to listen on specified port
    loop
        4.When connection is received, create new process to handle client