mirror of
https://github.com/morpheus65535/bazarr.git
synced 2024-11-10 09:02:44 +08:00
Added uptime to System-->Status
This commit is contained in:
parent
0f31c9858b
commit
55b7c9826b
6 changed files with 48 additions and 2 deletions
|
@ -23,6 +23,7 @@ from bs4 import BeautifulSoup as bso
|
|||
from get_args import args
|
||||
from config import settings, base_url, save_settings, get_settings
|
||||
from logger import empty_log
|
||||
from init import startTime
|
||||
|
||||
from init import *
|
||||
import logging
|
||||
|
@ -606,6 +607,7 @@ class SystemStatus(Resource):
|
|||
system_status.update({'python_version': platform.python_version()})
|
||||
system_status.update({'bazarr_directory': os.path.dirname(os.path.dirname(__file__))})
|
||||
system_status.update({'bazarr_config_directory': args.config_dir})
|
||||
system_status.update({'start_time': startTime})
|
||||
return jsonify(data=system_status)
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,11 @@ from helper import path_mappings
|
|||
from dogpile.cache.region import register_backend as register_cache_backend
|
||||
import subliminal
|
||||
import datetime
|
||||
import time
|
||||
|
||||
# set start time global variable as epoch
|
||||
global startTime
|
||||
startTime = time.time()
|
||||
|
||||
# set subliminal_patch user agent
|
||||
os.environ["SZ_USER_AGENT"] = "Bazarr/{}".format(os.environ["BAZARR_VERSION"])
|
||||
|
|
14
frontend/package-lock.json
generated
14
frontend/package-lock.json
generated
|
@ -19,6 +19,7 @@
|
|||
"axios": "^0.23",
|
||||
"bootstrap": "^4",
|
||||
"lodash": "^4",
|
||||
"moment": "^2.29.1",
|
||||
"rc-slider": "^9.7",
|
||||
"react": "^17",
|
||||
"react-bootstrap": "^1",
|
||||
|
@ -13780,6 +13781,14 @@
|
|||
"mkdirp": "bin/cmd.js"
|
||||
}
|
||||
},
|
||||
"node_modules/moment": {
|
||||
"version": "2.29.1",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
|
||||
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/move-concurrently": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",
|
||||
|
@ -32711,6 +32720,11 @@
|
|||
"minimist": "^1.2.5"
|
||||
}
|
||||
},
|
||||
"moment": {
|
||||
"version": "2.29.1",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
|
||||
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
|
||||
},
|
||||
"move-concurrently": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
"rooks": "^5.7.1",
|
||||
"sass": "^1",
|
||||
"socket.io-client": "^4",
|
||||
"typescript": "^4"
|
||||
"typescript": "^4",
|
||||
"moment": "^2.29.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bootstrap": "^5",
|
||||
|
|
1
frontend/src/@types/system.d.ts
vendored
1
frontend/src/@types/system.d.ts
vendored
|
@ -16,6 +16,7 @@ declare namespace System {
|
|||
python_version: string;
|
||||
radarr_version: string;
|
||||
sonarr_version: string;
|
||||
start_time: number;
|
||||
}
|
||||
|
||||
interface Health {
|
||||
|
|
|
@ -6,7 +6,8 @@ import {
|
|||
} from "@fortawesome/free-brands-svg-icons";
|
||||
import { faPaperPlane } from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import React, { FunctionComponent } from "react";
|
||||
import moment from "moment";
|
||||
import React, { FunctionComponent, useEffect, useState } from "react";
|
||||
import { Col, Container, Row } from "react-bootstrap";
|
||||
import { Helmet } from "react-helmet";
|
||||
import { useSystemHealth, useSystemStatus } from "../../@redux/hooks";
|
||||
|
@ -69,6 +70,25 @@ const SystemStatusView: FunctionComponent<Props> = () => {
|
|||
const health = useSystemHealth();
|
||||
const status = useSystemStatus();
|
||||
|
||||
const [uptime, setState] = useState<string>();
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
if (status) {
|
||||
let duration = moment.duration(
|
||||
moment().utc().unix() - status.start_time,
|
||||
"seconds"
|
||||
),
|
||||
days = duration.days(),
|
||||
hours = duration.hours().toString().padStart(2, "0"),
|
||||
minutes = duration.minutes().toString().padStart(2, "0"),
|
||||
seconds = duration.seconds().toString().padStart(2, "0");
|
||||
setState(days + "d " + hours + ":" + minutes + ":" + seconds);
|
||||
}
|
||||
}, 1000);
|
||||
return () => clearInterval(interval);
|
||||
}, [status]);
|
||||
|
||||
return (
|
||||
<Container className="p-5">
|
||||
<Helmet>
|
||||
|
@ -106,6 +126,9 @@ const SystemStatusView: FunctionComponent<Props> = () => {
|
|||
<CRow title="Bazarr Config Directory">
|
||||
<span>{status?.bazarr_config_directory}</span>
|
||||
</CRow>
|
||||
<CRow title="Uptime">
|
||||
<span>{uptime}</span>
|
||||
</CRow>
|
||||
</InfoContainer>
|
||||
</Row>
|
||||
<Row>
|
||||
|
|
Loading…
Reference in a new issue