Beispiel #1
0
    def setup_class(cls):
        set_cwd(tempfile.mkdtemp())
        cuckoo_create()

        # Don't judge me!
        with open(cwd("distributed", "settings.py"), "a+b") as f:
            f.write("\nSQLALCHEMY_DATABASE_URI = %r\n" % cls.URI)

        cls.app = create_app()
Beispiel #2
0
    def setup_class(cls):
        set_cwd(tempfile.mkdtemp())
        cuckoo_create()

        # Don't judge me!
        with open(cwd("distributed", "settings.py"), "a+b") as f:
            f.write("\nSQLALCHEMY_DATABASE_URI = %r\n" % cls.URI)

        cls.app = create_app()
Beispiel #3
0
def cuckoo_distributed_instance(name):
    app = create_app()

    with app.app_context():
        if name == "dist.scheduler":
            scheduler()
        elif name == "dist.status":
            status_caching()
        else:
            handle_node(name)
Beispiel #4
0
def cuckoo_distributed_instance(name):
    app = create_app()

    with app.app_context():
        if name == "dist.scheduler":
            scheduler()
        elif name == "dist.status":
            status_caching()
        else:
            handle_node(name)
Beispiel #5
0
 def create_app(self):
     return app.create_app()
Beispiel #6
0
    decide_cwd(exists=True)

    if not HAVE_GEVENT:
        sys.exit(
            "Please install Distributed Cuckoo dependencies (through "
            "`pip install cuckoo[distributed]`)"
        )

    formatter = logging.Formatter(
        "%(asctime)s [%(name)s] %(levelname)s: %(message)s"
    )

    fh = logging.handlers.WatchedFileHandler(cwd("log", "distributed.log"))
    fh.setFormatter(formatter)
    logging.getLogger().addHandler(fh)

    # Create the Flask object and push its context so that we can reuse the
    # database connection throughout our script.
    app = create_app()

    workers = {
        ("dist.scheduler", True): gevent.spawn(
            with_app, "dist.scheduler", scheduler
        ),
        ("dist.status", True): gevent.spawn(
            with_app, "dist.status", status_caching
        ),
    }

    with_app("dist.spawner", spawner)
 def create_app(self):
     return app.create_app()
Beispiel #8
0
def cuckoo_distributed(hostname, port, debug):
    app = create_app()
    app.run(host=hostname, port=port, debug=debug)
Beispiel #9
0
# See the file 'docs/LICENSE' for copying permission.

import os

from cuckoo.distributed.app import create_app
from cuckoo.distributed.instance import (
    scheduler, status_caching, handle_node
)
from cuckoo.misc import decide_cwd

app = None

def cuckoo_distributed(hostname, port, debug):
    app = create_app()
    app.run(host=hostname, port=port, debug=debug)

def cuckoo_distributed_instance(name):
    app = create_app()

    with app.app_context():
        if name == "dist.scheduler":
            scheduler()
        elif name == "dist.status":
            status_caching()
        else:
            handle_node(name)

if os.environ.get("CUCKOO_APP") == "dist":
    decide_cwd(exists=True)
    app = create_app()
Beispiel #10
0
def cuckoo_distributed(hostname, port, debug):
    app = create_app()
    app.run(host=hostname, port=port, debug=debug)