import intl from 'react-intl-universal'; import React, { useState, useEffect, useRef } from 'react'; import config from '@/utils/config'; import { request } from '@/utils/http'; import { PageLoading } from '@ant-design/pro-layout'; import { history, useOutletContext } from '@umijs/max'; import './index.less'; import { SharedContext } from '@/layouts'; import { Alert, Typography } from 'antd'; const Error = () => { const { user } = useOutletContext(); const [loading, setLoading] = useState(false); const [data, setData] = useState(intl.get('暂无日志')); const retryTimes = useRef(1); const getHealthStatus = (needLoading: boolean = true) => { needLoading && setLoading(true); request .get(`${config.apiPrefix}public/health`) .then(({ error, data }) => { if (data?.status === 1) { if (retryTimes.current > 1) { setTimeout(() => { window.location.reload(); }); } return; } if (retryTimes.current > 3) { setData(error?.details); return; } retryTimes.current += 1; setTimeout(() => { getHealthStatus(false); }, 3000); }) .finally(() => needLoading && setLoading(false)); }; useEffect(() => { if (user && user.username) { history.push('/crontab'); } }, [user]); useEffect(() => { getHealthStatus(); }, []); return (
{loading ? ( ) : retryTimes.current > 3 ? (
{intl.get('服务启动超时')} } description={
{intl.get('请先按如下方式修复:')}
1. 宿主机执行 docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower -cR <容器名>
{intl.get('2. 容器内执行 ql check、ql update')}
{intl.get( '3. 如果无法解决,容器内执行 pm2 logs,拷贝执行结果' )} {intl.get('提交 issue')}
} banner /> {data}
) : ( )}
); }; export default Error;