feat: add extension clean-up endpoint
This commit is contained in:
parent
230729483c
commit
7ec3045130
4 changed files with 29 additions and 6 deletions
18
views_api.py
18
views_api.py
|
|
@ -15,7 +15,7 @@ from lnbits.decorators import (
|
|||
)
|
||||
from lnbits.helpers import urlsafe_short_hash
|
||||
|
||||
from . import nostrrelay_ext
|
||||
from . import nostrrelay_ext, scheduled_tasks
|
||||
from .crud import (
|
||||
create_account,
|
||||
create_relay,
|
||||
|
|
@ -283,3 +283,19 @@ async def api_pay_to_join(data: BuyOrder):
|
|||
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||
detail="Cannot create invoice for client to join",
|
||||
)
|
||||
|
||||
|
||||
@nostrrelay_ext.delete("/api/v1", status_code=HTTPStatus.OK)
|
||||
async def api_stop(wallet: WalletTypeInfo = Depends(check_admin)):
|
||||
for t in scheduled_tasks:
|
||||
try:
|
||||
t.cancel()
|
||||
except Exception as ex:
|
||||
logger.warning(ex)
|
||||
|
||||
try:
|
||||
await client_manager.stop()
|
||||
except Exception as ex:
|
||||
logger.warning(ex)
|
||||
|
||||
return {"success": True}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue