from litepipeline.manager.models.applications import ApplicationsDB 
from litepipeline.manager import logger

LOG = logging.getLogger(__name__)

cwd = os.path.split(os.path.realpath(__file__))[0]



if __name__ == "__main__":
    logger.config_logging(file_name = "test_sqlite_applications.log",
                          log_level = "DEBUG",
                          dir_name = os.path.join(cwd, "logs"),
                          day_rotate = False,
                          when = "D",
                          interval = 1,
                          max_size = 20,
                          backup_count = 5,
                          console = True)

    LOG.debug("test start")
    
    try:
        app_id = ApplicationsDB.add("name 0", "description 0")
        app_id = ApplicationsDB.add("name 1", "description 1")
        app_id = ApplicationsDB.add("name 2", "description 2")
        r = ApplicationsDB.get(app_id)
        LOG.debug("get: %s", r)
        r = ApplicationsDB.list()
        LOG.debug("list: %s", r)
Пример #2
0
def main():
    parser = argparse.ArgumentParser(prog='litemanager')
    parser.add_argument("-c",
                        "--config",
                        required=True,
                        help="configuration file path")
    parser.add_argument("-v",
                        "--version",
                        action='version',
                        version='%(prog)s ' + __version__)
    args = parser.parse_args()

    if args.config:
        success = load_config(args.config)
        if success:
            common.init_storage()
            logger.config_logging(file_name="manager.log",
                                  log_level=CONFIG["log_level"],
                                  dir_name=CONFIG["log_path"],
                                  day_rotate=False,
                                  when="D",
                                  interval=1,
                                  max_size=20,
                                  backup_count=5,
                                  console=True)

            LOG.info("service start")

            try:
                if CONFIG["ldfs_http_host"] and CONFIG["ldfs_http_port"]:
                    LDFS = LiteDFS(CONFIG["ldfs_http_host"],
                                   CONFIG["ldfs_http_port"])
                venvs_db = Venvs()
                venv_history_db = VenvHistory()
                tasks_db = Tasks()
                applications_db = Applications()
                application_history_db = ApplicationHistory()
                workflows_db = Workflows()
                works_db = Works()
                schedules_db = Schedules()
                services_db = Services()
                venv_manager = VenvManager()
                app_manager = AppManager()
                task_scheduler = Scheduler(CONFIG["scheduler_interval"])
                http_server = tornado.httpserver.HTTPServer(
                    Application(),
                    max_buffer_size=CONFIG["max_buffer_size"],
                    chunk_size=10 * 1024 * 1024)
                http_server.listen(CONFIG["http_port"],
                                   address=CONFIG["http_host"])
                # http_server.bind(CONFIG["http_port"], address = CONFIG["http_host"])
                listener = DiscoveryListener(Connection, task_scheduler)
                listener.listen(CONFIG["tcp_port"], CONFIG["tcp_host"])
                stop_service.Servers.HTTP_SERVER = http_server
                stop_service.Servers.SERVERS.append(task_scheduler)
                stop_service.Servers.SERVERS.append(venvs_db)
                stop_service.Servers.SERVERS.append(venv_history_db)
                stop_service.Servers.SERVERS.append(applications_db)
                stop_service.Servers.SERVERS.append(application_history_db)
                stop_service.Servers.SERVERS.append(tasks_db)
                stop_service.Servers.SERVERS.append(workflows_db)
                stop_service.Servers.SERVERS.append(works_db)
                stop_service.Servers.SERVERS.append(schedules_db)
                stop_service.Servers.SERVERS.append(services_db)
                stop_service.Servers.SERVERS.append(venv_manager)
                stop_service.Servers.SERVERS.append(app_manager)
                signal.signal(signal.SIGTERM, stop_service.sig_handler)
                signal.signal(signal.SIGINT, stop_service.sig_handler)
                tornado.ioloop.IOLoop.instance().start()
            except Exception as e:
                LOG.exception(e)

            LOG.info("service end")
        else:
            print("failed to load configuration: %s" % args.config)
    else:
        parser.print_help()
    print(response)
    fp.close()


@gen.coroutine
def on_chunk(chunk):
    print(len(chunk))
    fp.write(chunk)


if __name__ == "__main__":
    logger.config_logging(file_name="test_tornado_httpclient_async.log",
                          log_level="DEBUG",
                          dir_name=os.path.join(cwd, "logs"),
                          day_rotate=False,
                          when="D",
                          interval=1,
                          max_size=20,
                          backup_count=5,
                          console=True)

    LOG.debug("test start")

    try:
        url = "http://127.0.0.1:8000/app/download?app_id=d6c1341c-a40b-44e3-91dd-de4042ef5346"
        client = AsyncHTTPClient()
        request = HTTPRequest(url=url, streaming_callback=on_chunk)
        client.fetch(request, on_done)
        IOLoop.current().start()
    except Exception as e:
        LOG.exception(e)
Пример #4
0
                        "--config",
                        required=True,
                        help="configuration file path")
    parser.add_argument("-v",
                        "--version",
                        action='version',
                        version='%(prog)s ' + __version__)
    args = parser.parse_args()
    if args.config:
        success = load_config(args.config)
        if success:
            logger.config_logging(file_name="migrate_database.log",
                                  log_level=CONFIG["log_level"],
                                  dir_name=CONFIG["log_path"],
                                  day_rotate=False,
                                  when="D",
                                  interval=1,
                                  max_size=20,
                                  backup_count=5,
                                  console=True)

            LOG.info("migrate start")
            engine, _ = ApplicationsTable.init_engine_and_session()
            application_name_index.create(bind=engine)

            engine, _ = TasksTable.init_engine_and_session()
            task_name_index.create(bind=engine)
            task_start_at_index.create(bind=engine)
            task_end_at_index.create(bind=engine)
            task_status_index.create(bind=engine)