Add time cost when start servers (#12552)

### What problem does this PR solve?

- API server
- Ingestion server
- Data sync server
- Admin server

### Type of change

- [x] Refactoring

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-01-12 12:48:23 +08:00
committed by GitHub
parent 638c510468
commit a7dd3b7e9e
4 changed files with 19 additions and 7 deletions

View File

@ -14,10 +14,12 @@
# limitations under the License. # limitations under the License.
# #
import time
start_ts = time.time()
import os import os
import signal import signal
import logging import logging
import time
import threading import threading
import traceback import traceback
import faulthandler import faulthandler
@ -66,7 +68,7 @@ if __name__ == '__main__':
SERVICE_CONFIGS.configs = load_configurations(SERVICE_CONF) SERVICE_CONFIGS.configs = load_configurations(SERVICE_CONF)
try: try:
logging.info("RAGFlow Admin service start...") logging.info(f"RAGFlow admin is ready after {time.time() - start_ts}s initialization.")
run_simple( run_simple(
hostname="0.0.0.0", hostname="0.0.0.0",
port=9381, port=9381,

View File

@ -18,8 +18,8 @@
# from beartype.claw import beartype_all # <-- you didn't sign up for this # from beartype.claw import beartype_all # <-- you didn't sign up for this
# beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all code # beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all code
from common.log_utils import init_root_logger import time
from plugin import GlobalPluginManager start_ts = time.time()
import logging import logging
import os import os
@ -40,6 +40,8 @@ from api.db.init_data import init_web_data, init_superuser
from common.versions import get_ragflow_version from common.versions import get_ragflow_version
from common.config_utils import show_configs from common.config_utils import show_configs
from common.mcp_tool_call_conn import shutdown_all_mcp_sessions from common.mcp_tool_call_conn import shutdown_all_mcp_sessions
from common.log_utils import init_root_logger
from plugin import GlobalPluginManager
from rag.utils.redis_conn import RedisDistributedLock from rag.utils.redis_conn import RedisDistributedLock
stop_event = threading.Event() stop_event = threading.Event()
@ -145,7 +147,7 @@ if __name__ == '__main__':
# start http server # start http server
try: try:
logging.info("RAGFlow HTTP server start...") logging.info(f"RAGFlow server is ready after {time.time() - start_ts}s initialization.")
app.run(host=settings.HOST_IP, port=settings.HOST_PORT) app.run(host=settings.HOST_IP, port=settings.HOST_PORT)
except Exception: except Exception:
traceback.print_exc() traceback.print_exc()

View File

@ -19,6 +19,9 @@
# beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all code # beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all code
import time
start_ts = time.time()
import asyncio import asyncio
import copy import copy
import faulthandler import faulthandler
@ -27,7 +30,6 @@ import os
import signal import signal
import sys import sys
import threading import threading
import time
import traceback import traceback
from datetime import datetime, timezone from datetime import datetime, timezone
from typing import Any from typing import Any
@ -1266,6 +1268,7 @@ async def main():
signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler) signal.signal(signal.SIGTERM, signal_handler)
logging.info(f"RAGFlow data sync is ready after {time.time() - start_ts}s initialization.")
while not stop_event.is_set(): while not stop_event.is_set():
await dispatch_tasks() await dispatch_tasks()
logging.error("BUG!!! You should not reach here!!!") logging.error("BUG!!! You should not reach here!!!")

View File

@ -12,6 +12,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import time
start_ts = time.time()
import asyncio import asyncio
import socket import socket
import concurrent import concurrent
@ -21,7 +25,6 @@ import concurrent
import random import random
import sys import sys
import threading import threading
import time
from api.db import PIPELINE_SPECIAL_PROGRESS_FREEZE_TASK_TYPES from api.db import PIPELINE_SPECIAL_PROGRESS_FREEZE_TASK_TYPES
from api.db.services.knowledgebase_service import KnowledgebaseService from api.db.services.knowledgebase_service import KnowledgebaseService
@ -1322,6 +1325,8 @@ async def main():
report_task = asyncio.create_task(report_status()) report_task = asyncio.create_task(report_status())
tasks = [] tasks = []
logging.info(f"RAGFlow ingestion is ready after {time.time() - start_ts}s initialization.")
try: try:
while not stop_event.is_set(): while not stop_event.is_set():
await task_limiter.acquire() await task_limiter.acquire()