123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- from fastapi import FastAPI
- from fastapi.middleware.cors import CORSMiddleware
- from app.core.airflow.job import AirflowJobSubmitter
- from app.models.database import engine, Base
- import app.routers.job_jdbc_datasource as router_jjds
- import app.routers.constants as router_constants
- import app.routers.job_info as router_job_info
- import app.routers.job_log as router_job_log
- import app.routers.datax_json as router_datax
- import app.routers.data_management as router_data_management
- import app.routers.files as router_files
- import app.routers.jm_homework as router_jm_homework
- import app.routers.dag as router_dag
- import app.routers.code_check as router_code_check
- import app.routers.jm_job_info as router_jm_job_info
- import app.routers.jm_job_log as router_jm_job_log
- import app.routers.auth as router_auth
- import app.routers.programme as router_programme
- from app.routers.run import router_af_run
- from app.routers.job import router_af_job
- from app.routers.task import router_af_task
- from configs.globals import GlobalsMiddleware
- from utils.sx_log import format_print
- import os
- format_print()
- PREFIX = os.environ.get('APP_PREFIX', default='jpt')
- print(f'prefix: {PREFIX}')
- Base.metadata.create_all(bind=engine)
- app = FastAPI(docs_url=f'/{PREFIX}/docs', redoc_url=f'/{PREFIX}/redoc', openapi_url=f'/{PREFIX}/openapi.json', title="DAG In Airflow管理系统")
- # CORS 跨源资源共享
- app.add_middleware(
- CORSMiddleware,
- allow_origins=["*"],
- allow_credentials=True,
- allow_methods=["*"],
- allow_headers=["*"],
- )
- app.add_middleware(GlobalsMiddleware)
- app.include_router(router_auth.router)
- app.include_router(router_programme.router)
- app.include_router(router_jjds.router)
- app.include_router(router_constants.router)
- app.include_router(router_job_info.router)
- app.include_router(router_job_log.router)
- app.include_router(router_data_management.router)
- app.include_router(router_datax.router)
- app.include_router(router_files.router)
- app.include_router(router_jm_homework.router)
- app.include_router(router_dag.router)
- app.include_router(router_af_task)
- app.include_router(router_af_job)
- app.include_router(router_af_run)
- app.include_router(router_jm_job_info.router)
- app.include_router(router_jm_job_log.router)
- app.include_router(router_code_check.router)
- if PREFIX == 'af':
- AirflowJobSubmitter.auto_submit_data_transfer()
- AirflowJobSubmitter.auto_submit_requirements_install()
- print('server init finish:)!!!')
- # Get 健康检查
- @app.get(f"/{PREFIX}/ping", description="健康检查")
- def ping():
- return "pong!!"
|