2024-08-15 09:17:36 +08:00
|
|
|
#
|
|
|
|
# Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
|
|
|
|
import logging
|
2024-11-14 17:13:48 +08:00
|
|
|
from api.utils.log_utils import initRootLogger
|
2024-11-15 14:43:55 +08:00
|
|
|
initRootLogger("ragflow_server")
|
2024-11-14 17:13:48 +08:00
|
|
|
for module in ["pdfminer"]:
|
|
|
|
module_logger = logging.getLogger(module)
|
|
|
|
module_logger.setLevel(logging.WARNING)
|
|
|
|
for module in ["peewee"]:
|
|
|
|
module_logger = logging.getLogger(module)
|
|
|
|
module_logger.handlers.clear()
|
|
|
|
module_logger.propagate = True
|
|
|
|
|
2024-08-15 09:17:36 +08:00
|
|
|
import os
|
|
|
|
import signal
|
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
import traceback
|
|
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
|
|
|
|
|
|
from werkzeug.serving import run_simple
|
2024-11-15 17:30:56 +08:00
|
|
|
from api import settings
|
2024-08-15 09:17:36 +08:00
|
|
|
from api.apps import app
|
|
|
|
from api.db.runtime_config import RuntimeConfig
|
|
|
|
from api.db.services.document_service import DocumentService
|
|
|
|
from api import utils
|
|
|
|
|
|
|
|
from api.db.db_models import init_database_tables as init_web_db
|
|
|
|
from api.db.init_data import init_web_data
|
2024-11-14 17:51:21 +08:00
|
|
|
from api.versions import get_ragflow_version
|
Print configs when startup RAGFlow server (#3414)
### What problem does this PR solve?
Print configs at the RAGFlow startup phase.
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
```
2024-11-14 21:27:53,090 INFO 962231 Current configs, from /home/weilongma/Documents/development/ragflow/conf/service_conf.yaml:
2024-11-14 21:27:53,090 INFO 962231 ragflow: {'host': '0.0.0.0', 'http_port': 9380}
2024-11-14 21:27:53,090 INFO 962231 mysql: {'name': 'rag_flow', 'user': 'root', 'password': 'infini_rag_flow', 'host': 'mysql', 'port': 5455, 'max_connections': 100, 'stale_timeout': 30}
2024-11-14 21:27:53,090 INFO 962231 minio: {'user': 'rag_flow', 'password': 'infini_rag_flow', 'host': 'minio:9000'}
2024-11-14 21:27:53,090 INFO 962231 es: {'hosts': 'http://es01:1200', 'username': 'elastic', 'password': 'infini_rag_flow'}
2024-11-14 21:27:53,090 INFO 962231 redis: {'db': 1, 'password': 'infini_rag_flow', 'host': 'redis:6379'}
```
Signed-off-by: jinhai <haijin.chn@gmail.com>
2024-11-15 09:29:40 +08:00
|
|
|
from api.utils import show_configs
|
2024-08-15 09:17:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
def update_progress():
|
|
|
|
while True:
|
2024-10-16 16:10:24 +08:00
|
|
|
time.sleep(3)
|
2024-08-15 09:17:36 +08:00
|
|
|
try:
|
|
|
|
DocumentService.update_progress()
|
2024-11-12 17:35:13 +08:00
|
|
|
except Exception:
|
2024-11-14 17:13:48 +08:00
|
|
|
logging.exception("update_progress exception")
|
2024-08-15 09:17:36 +08:00
|
|
|
|
|
|
|
|
2024-11-12 17:35:13 +08:00
|
|
|
if __name__ == '__main__':
|
2024-11-14 17:13:48 +08:00
|
|
|
logging.info(r"""
|
2024-09-29 16:28:07 +08:00
|
|
|
____ ___ ______ ______ __
|
|
|
|
/ __ \ / | / ____// ____// /____ _ __
|
|
|
|
/ /_/ // /| | / / __ / /_ / // __ \| | /| / /
|
|
|
|
/ _, _// ___ |/ /_/ // __/ / // /_/ /| |/ |/ /
|
|
|
|
/_/ |_|/_/ |_|\____//_/ /_/ \____/ |__/|__/
|
2024-08-15 09:17:36 +08:00
|
|
|
|
2024-11-12 17:35:13 +08:00
|
|
|
""")
|
2024-11-14 17:13:48 +08:00
|
|
|
logging.info(
|
2024-11-14 17:51:21 +08:00
|
|
|
f'RAGFlow version: {get_ragflow_version()}'
|
2024-11-14 15:51:30 +08:00
|
|
|
)
|
2024-11-14 17:13:48 +08:00
|
|
|
logging.info(
|
2024-11-12 17:35:13 +08:00
|
|
|
f'project base: {utils.file_utils.get_project_base_directory()}'
|
2024-08-15 09:17:36 +08:00
|
|
|
)
|
Print configs when startup RAGFlow server (#3414)
### What problem does this PR solve?
Print configs at the RAGFlow startup phase.
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
```
2024-11-14 21:27:53,090 INFO 962231 Current configs, from /home/weilongma/Documents/development/ragflow/conf/service_conf.yaml:
2024-11-14 21:27:53,090 INFO 962231 ragflow: {'host': '0.0.0.0', 'http_port': 9380}
2024-11-14 21:27:53,090 INFO 962231 mysql: {'name': 'rag_flow', 'user': 'root', 'password': 'infini_rag_flow', 'host': 'mysql', 'port': 5455, 'max_connections': 100, 'stale_timeout': 30}
2024-11-14 21:27:53,090 INFO 962231 minio: {'user': 'rag_flow', 'password': 'infini_rag_flow', 'host': 'minio:9000'}
2024-11-14 21:27:53,090 INFO 962231 es: {'hosts': 'http://es01:1200', 'username': 'elastic', 'password': 'infini_rag_flow'}
2024-11-14 21:27:53,090 INFO 962231 redis: {'db': 1, 'password': 'infini_rag_flow', 'host': 'redis:6379'}
```
Signed-off-by: jinhai <haijin.chn@gmail.com>
2024-11-15 09:29:40 +08:00
|
|
|
show_configs()
|
2024-11-15 17:30:56 +08:00
|
|
|
settings.init_settings()
|
2024-08-15 09:17:36 +08:00
|
|
|
|
|
|
|
# init db
|
|
|
|
init_web_db()
|
|
|
|
init_web_data()
|
|
|
|
# init runtime config
|
|
|
|
import argparse
|
2024-11-04 08:35:36 +01:00
|
|
|
|
2024-08-15 09:17:36 +08:00
|
|
|
parser = argparse.ArgumentParser()
|
2024-11-04 08:35:36 +01:00
|
|
|
parser.add_argument(
|
Print configs when startup RAGFlow server (#3414)
### What problem does this PR solve?
Print configs at the RAGFlow startup phase.
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
```
2024-11-14 21:27:53,090 INFO 962231 Current configs, from /home/weilongma/Documents/development/ragflow/conf/service_conf.yaml:
2024-11-14 21:27:53,090 INFO 962231 ragflow: {'host': '0.0.0.0', 'http_port': 9380}
2024-11-14 21:27:53,090 INFO 962231 mysql: {'name': 'rag_flow', 'user': 'root', 'password': 'infini_rag_flow', 'host': 'mysql', 'port': 5455, 'max_connections': 100, 'stale_timeout': 30}
2024-11-14 21:27:53,090 INFO 962231 minio: {'user': 'rag_flow', 'password': 'infini_rag_flow', 'host': 'minio:9000'}
2024-11-14 21:27:53,090 INFO 962231 es: {'hosts': 'http://es01:1200', 'username': 'elastic', 'password': 'infini_rag_flow'}
2024-11-14 21:27:53,090 INFO 962231 redis: {'db': 1, 'password': 'infini_rag_flow', 'host': 'redis:6379'}
```
Signed-off-by: jinhai <haijin.chn@gmail.com>
2024-11-15 09:29:40 +08:00
|
|
|
"--version", default=False, help="RAGFlow version", action="store_true"
|
2024-11-04 08:35:36 +01:00
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--debug", default=False, help="debug mode", action="store_true"
|
|
|
|
)
|
2024-08-15 09:17:36 +08:00
|
|
|
args = parser.parse_args()
|
|
|
|
if args.version:
|
2024-11-14 17:51:21 +08:00
|
|
|
print(get_ragflow_version())
|
2024-08-15 09:17:36 +08:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
RuntimeConfig.DEBUG = args.debug
|
|
|
|
if RuntimeConfig.DEBUG:
|
2024-11-14 17:13:48 +08:00
|
|
|
logging.info("run on debug mode")
|
2024-08-15 09:17:36 +08:00
|
|
|
|
|
|
|
RuntimeConfig.init_env()
|
2024-11-15 17:30:56 +08:00
|
|
|
RuntimeConfig.init_config(JOB_SERVER_HOST=settings.HOST_IP, HTTP_PORT=settings.HOST_PORT)
|
2024-08-15 09:17:36 +08:00
|
|
|
|
Print configs when startup RAGFlow server (#3414)
### What problem does this PR solve?
Print configs at the RAGFlow startup phase.
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
```
2024-11-14 21:27:53,090 INFO 962231 Current configs, from /home/weilongma/Documents/development/ragflow/conf/service_conf.yaml:
2024-11-14 21:27:53,090 INFO 962231 ragflow: {'host': '0.0.0.0', 'http_port': 9380}
2024-11-14 21:27:53,090 INFO 962231 mysql: {'name': 'rag_flow', 'user': 'root', 'password': 'infini_rag_flow', 'host': 'mysql', 'port': 5455, 'max_connections': 100, 'stale_timeout': 30}
2024-11-14 21:27:53,090 INFO 962231 minio: {'user': 'rag_flow', 'password': 'infini_rag_flow', 'host': 'minio:9000'}
2024-11-14 21:27:53,090 INFO 962231 es: {'hosts': 'http://es01:1200', 'username': 'elastic', 'password': 'infini_rag_flow'}
2024-11-14 21:27:53,090 INFO 962231 redis: {'db': 1, 'password': 'infini_rag_flow', 'host': 'redis:6379'}
```
Signed-off-by: jinhai <haijin.chn@gmail.com>
2024-11-15 09:29:40 +08:00
|
|
|
thread = ThreadPoolExecutor(max_workers=1)
|
|
|
|
thread.submit(update_progress)
|
2024-08-15 09:17:36 +08:00
|
|
|
|
|
|
|
# start http server
|
|
|
|
try:
|
2024-11-14 17:51:21 +08:00
|
|
|
logging.info("RAGFlow HTTP server start...")
|
2024-11-04 08:35:36 +01:00
|
|
|
run_simple(
|
2024-11-15 17:30:56 +08:00
|
|
|
hostname=settings.HOST_IP,
|
|
|
|
port=settings.HOST_PORT,
|
2024-11-04 08:35:36 +01:00
|
|
|
application=app,
|
|
|
|
threaded=True,
|
|
|
|
use_reloader=RuntimeConfig.DEBUG,
|
|
|
|
use_debugger=RuntimeConfig.DEBUG,
|
|
|
|
)
|
2024-08-15 09:17:36 +08:00
|
|
|
except Exception:
|
|
|
|
traceback.print_exc()
|
2024-11-04 08:35:36 +01:00
|
|
|
os.kill(os.getpid(), signal.SIGKILL)
|