예제 #1
0
def sync(lock):
    """
    A thread that will sync Leases with the local rethinkdb
    """
    # db connection is shared between threads
    dbconnection = connect()

    logger = logging.getLogger('myslice.leases')
    while True:
        logger.info("syncing Leases")
        try:
            syncLeases()
        except Exception as e:
            logger.exception(e)
            continue
        logger.info("sleeping")

        # sleep for 5 minutes
        # to be fine tuned
        time.sleep(300)
예제 #2
0
파일: events.py 프로젝트: cemdrk/myslice2
##
#   MySlice version 2
#
#   Events thread worker
#
#   (c) 2016 Ciro Scognamiglio <*****@*****.**>, Radomir Klacza <*****@*****.**>
##

import myslice.db as db
from myslice.db import connect, dispatch
from myslice.db.activity import Event, ObjectType
from myslice.db.user import User
import myslice.lib.log as logging

logger = logging.getLogger("activity")


def run(q):
    """
    Manages newly created events
    """
    logger.info("Worker activity events starting")

    # db connection is shared between threads
    dbconnection = connect()

    while True:
        try:
            event = Event(q.get())
        except Exception as e:
            import traceback
예제 #3
0
파일: activity.py 프로젝트: cemdrk/myslice2
import random

import myslice.db as db
import rethinkdb as r

from myslice.db import connect, changes, events
from myslice.db.activity import Event, EventStatus
from myslice.services.workers.events import run as manageEvents
import myslice.lib.log as logging

import zmq
import pickle
import json


logger = logging.getLogger()


def receive_signal(signum, stack):
    logger.info('Received signal %s', signum)
    raise SystemExit('Exiting')

def run():
    """

    """
    signal.signal(signal.SIGINT, receive_signal)
    signal.signal(signal.SIGTERM, receive_signal)
    signal.signal(signal.SIGHUP, receive_signal)

    qEvents = Queue()
예제 #4
0
import signal
import threading
from queue import Queue
import myslice.db as db
import rethinkdb as r
from myslice.db import changes, connect, events
from myslice.db.activity import Event, ObjectType
from myslice.services.workers.projects import events_run as manageProjects, sync as syncProjects
from myslice.services.workers.slices import events_run as manageSlices, sync as syncSlices
import myslice.lib.log as logging
from myslice import config
import zmq
import pickle

logger = logging.getLogger("experiments")


def receive_signal(signum, stack):
    logger.info('Received signal %s', signum)

    raise SystemExit('Exiting')


def run():
    """
    A Process that will manage Projects and Slices 
    """
    signal.signal(signal.SIGINT, receive_signal)
    signal.signal(signal.SIGTERM, receive_signal)
    signal.signal(signal.SIGHUP, receive_signal)
예제 #5
0
import threading
from queue import Queue
import rethinkdb as r

from myslice import config
from myslice.db.activity import Event, ObjectType
from myslice.db import connect, changes, events
from myslice.services.workers.users import events_run as manageUsersEvents
from myslice.services.workers.password import events_run as managePasswordEvents
from myslice.services.workers.users import sync as syncUsers
import myslice.lib.log as logging
from myslice import config
import zmq
import pickle

logger = logging.getLogger("users")


def receive_signal(signum, stack):
    logger.info('Received signal %s', signum)

    raise SystemExit('Exiting')


def run():
    """

    """
    signal.signal(signal.SIGINT, receive_signal)
    signal.signal(signal.SIGTERM, receive_signal)
    signal.signal(signal.SIGHUP, receive_signal)
예제 #6
0
파일: __init__.py 프로젝트: cemdrk/myslice2
#from myslice.web.rest.finterop.resource import ResourceRepoHandler

from myslice.web.rest.activity import ActivityHandler
from myslice.web.rest.confirm import ConfirmHandler

##
# WebSocket handler
from myslice.web.websocket import WebsocketsHandler

##
# Web controllers
from myslice.web.controllers import addOrganization, activity, confirm, home, login, logout, password, projects, registration, slices, status, users
from myslice.web.controllers import test

logger = logging.getLogger("web")


def run():
    logger.info("Starting web server")

    IOLoop.current().run_sync(WebServer)

    try:
        IOLoop.instance().start()
    except KeyboardInterrupt:
        IOLoop.instance().stop()
    except Exception as e:
        print(e)
        exit(1)
예제 #7
0
파일: emails.py 프로젝트: cemdrk/myslice2
#   (c) 2016 Ciro Scognamiglio <*****@*****.**>
##

import signal
import threading
from queue import Queue
import rethinkdb as r
from myslice.db import connect, changes, events
from myslice.db.activity import Event
from myslice.services.workers.emails import emails_run as manageEmails, confirmEmails
import myslice.lib.log as logging

import zmq
import pickle

logger = logging.getLogger("emails")


def receive_signal(signum, stack):
    logger.info('Received signal %s', signum)
    raise SystemExit('Exiting')


def run():
    """

    """
    signal.signal(signal.SIGINT, receive_signal)
    signal.signal(signal.SIGTERM, receive_signal)
    signal.signal(signal.SIGHUP, receive_signal)
예제 #8
0
파일: leases.py 프로젝트: cemdrk/myslice2
##

import signal
import threading
from queue import Queue
import myslice.db as db
import rethinkdb as r
from myslice.db import changes, connect, events
from myslice.db.activity import Event, ObjectType
from myslice.services.workers.leases import events_run as manageLeases, sync as syncLeases
import myslice.lib.log as logging
from myslice import config
import zmq
import pickle

logger = logging.getLogger("leases")


def receive_signal(signum, stack):
    logger.info('Received signal %s', signum)

    raise SystemExit('Exiting')


def run():
    """
    A Process that will manage Leases 
    """
    signal.signal(signal.SIGINT, receive_signal)
    signal.signal(signal.SIGTERM, receive_signal)
    signal.signal(signal.SIGHUP, receive_signal)
예제 #9
0
import myslice.db as db
from myslice.lib import Status
from myslice.lib.util import format_date

from myslice.lib.authentication import UserSetup
from myslice import myslicelibsetup

from myslice.db.activity import Event, ObjectType, DataType
from myslice.db import changes, connect
from myslice.db.user import User
from myslice.db.project import Project
from myslicelib.query import q
import myslice.lib.log as logging

logger = logging.getLogger("projects")

def events_run(lock, qProjectEvents):
    """
    Process the authority after approval 
    """

    logger.info("Worker authorities events starting") 

    # db connection is shared between threads
    dbconnection = connect()

    while True:

        try:
            event = Event(qProjectEvents.get())
예제 #10
0
    This service will run multiple threads responsible for watching for changes
    to rethinkdb and broadcast to connected clients with ZeroMQ

    (c) 2017 Radomir Klacza <*****@*****.**>
'''

import myslice.lib.log as logging
import signal
from myslice.db.activity import Event, ObjectType
import rethinkdb as r
import zmq
import pickle
from myslice.db import connect, changes, tables, events

logger = logging.getLogger('myslice-router')


def receive_signal(signum, stack):
    logger.info('Received signal %s', signum)
    raise SystemExit('Exiting')



def filter_channels(event):

    """
    findings all channels that message needs to be send to
    :param event: 
    :return:[] of channels that we need to send messages to 
    """