Skip to content

Commit 077866f

Browse files
committed
fix(node): notification error
1 parent 359d7b0 commit 077866f

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

app/jobs/node_checker.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from app.operation import OperatorType
1313
from app.db.crud.node import get_limited_nodes
1414

15-
from config import JOB_CORE_HEALTH_CHECK_INTERVAL
15+
from config import JOB_CORE_HEALTH_CHECK_INTERVAL, JOB_CHECK_NODE_LIMITS_INTERVAL
1616

1717

1818
node_operator = NodeOperation(operator_type=OperatorType.SYSTEM)
@@ -158,9 +158,6 @@ async def node_health_check():
158158
check_tasks = [process_node_health_check(db_node, dict_nodes.get(db_node.id)) for db_node in db_nodes]
159159
await asyncio.gather(*check_tasks, return_exceptions=True)
160160

161-
# Check for nodes that exceeded data limits
162-
await check_node_limits()
163-
164161

165162
@on_startup
166163
async def initialize_nodes():
@@ -175,10 +172,16 @@ async def initialize_nodes():
175172
await node_operator.connect_nodes_bulk(db, db_nodes)
176173
logger.info("All nodes' cores have been started.")
177174

175+
# Schedule node health check job (runs frequently)
178176
scheduler.add_job(
179177
node_health_check, "interval", seconds=JOB_CORE_HEALTH_CHECK_INTERVAL, coalesce=True, max_instances=1
180178
)
181179

180+
# Schedule node limits check job (runs less frequently)
181+
scheduler.add_job(
182+
check_node_limits, "interval", seconds=JOB_CHECK_NODE_LIMITS_INTERVAL, coalesce=True, max_instances=1
183+
)
184+
182185

183186
@on_shutdown
184187
async def shutdown_nodes():

app/notification/discord/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .host import create_host, modify_host, remove_host, modify_hosts
22
from .user_template import create_user_template, modify_user_template, remove_user_template
3-
from .node import create_node, modify_node, remove_node, connect_node, error_node
3+
from .node import create_node, modify_node, remove_node, connect_node, error_node, limited_node
44
from .group import create_group, modify_group, remove_group
55
from .core import create_core, modify_core, remove_core
66
from .admin import create_admin, modify_admin, remove_admin, admin_reset_usage, admin_login
@@ -27,6 +27,7 @@
2727
"remove_node",
2828
"connect_node",
2929
"error_node",
30+
"limited_node",
3031
"create_group",
3132
"modify_group",
3233
"remove_group",

app/notification/telegram/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .host import create_host, modify_host, remove_host, modify_hosts
22
from .user_template import create_user_template, modify_user_template, remove_user_template
3-
from .node import create_node, modify_node, remove_node, connect_node, error_node
3+
from .node import create_node, modify_node, remove_node, connect_node, error_node, limited_node
44
from .group import create_group, modify_group, remove_group
55
from .core import create_core, modify_core, remove_core
66
from .admin import create_admin, modify_admin, remove_admin, admin_reset_usage, admin_login
@@ -27,6 +27,7 @@
2727
"remove_node",
2828
"connect_node",
2929
"error_node",
30+
"limited_node",
3031
"create_group",
3132
"modify_group",
3233
"remove_group",

config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,5 @@
9797
JOB_REMOVE_EXPIRED_USERS_INTERVAL = config("JOB_REMOVE_EXPIRED_USERS_INTERVAL", cast=int, default=3600)
9898
JOB_RESET_USER_DATA_USAGE_INTERVAL = config("JOB_RESET_USER_DATA_USAGE_INTERVAL", cast=int, default=600)
9999
JOB_RESET_NODE_USAGE_INTERVAL = config("JOB_RESET_NODE_USAGE_INTERVAL", cast=int, default=60)
100+
JOB_CHECK_NODE_LIMITS_INTERVAL = config("JOB_CHECK_NODE_LIMITS_INTERVAL", cast=int, default=60)
100101
JOB_CLEANUP_SUBSCRIPTION_UPDATES_INTERVAL = config("JOB_CLEANUP_SUBSCRIPTION_UPDATES_INTERVAL", cast=int, default=600)

0 commit comments

Comments
 (0)