Esempio n. 1
0
    def main(testmode=False, workdir=lib_folder):
        if MynedataBackendCtl.backend_process is not None:
            return
        if not Configuration.initialized:
            Configuration.initialize()

        mynedata_backend_command = 'celery worker {tasks} {workdir} {celerybeat} {testmode} {logfile} {loglevel} {autoscale}'.format(
            tasks='-A lib.backend.tasks.app -B',
            workdir='--workdir {}'.format(workdir),
            celerybeat='--schedule=/tmp/celerybeat-schedule',
            testmode='--testmode' if testmode else '',
            logfile='--logfile=/opt/mynedata/log/backend.log',
            loglevel='--loglevel=debug',
            autoscale='--autoscale %s,%s' %
            (Configuration.concurrency_max, Configuration.concurrency_min),
        )

        if testmode:
            Configuration.enable_test_mode()
        Configuration.print_config()

        MynedataBackendCtl.backend_process = subprocess.Popen(
            mynedata_backend_command, shell=True)
        with open(PID_FILE, 'w') as f_pid:
            f_pid.write(str(MynedataBackendCtl.backend_process.pid) + '\n')
Esempio n. 2
0
    def __init__(self, worker, test_mode, **options):
        Configuration.initialize()
        if test_mode:
            Configuration.enable_test_mode()
        Configuration.print_config()
        worker.app.config_from_object(Configuration)
        DatabaseConnector.initialize(target=Configuration.database_uri)

        # Initialize payments
        if Configuration.payment_mode in [
                PaymentMethod.BITCOIN_DIRECT,
                PaymentMethod.BITCOIN_QUERY_BASED,
                PaymentMethod.BITCOIN_CENTRAL
        ]:
            BitcoinConnector.initialize()
Esempio n. 3
0
#!/usr/bin/env python3

""" This script starts the myneData API. """

import sys
import os
from gevent import monkey

lib_folder = '/'.join(os.path.split(os.path.dirname(sys.path[0]))[:-1])
sys.path.insert(0, lib_folder)

from lib.config import Configuration
from lib.api import endpoint
monkey.patch_all()


if __name__ == '__main__':
    Configuration.initialize()
    Configuration.print_config()

    endpoint.app.debug = True
    endpoint.app.run(port=int(Configuration.api_port), server='gevent')