Fix Cronicle event: use HTTP plugin (no shell needed) and every-minute timing
- Switch shellplug → urlplug to avoid spawn errors in shell-less containers
- Explicitly set timing to all 60 minutes (Cronicle {} defaults to hourly :00)
- Restore RAGGR_INTERNAL_URL env var for the HTTP plugin target URL
Delete the existing broken Cronicle event before redeploying so it gets recreated.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -129,6 +129,8 @@ CRON_SECRET=
|
||||
# Used to auto-register scheduled jobs on startup.
|
||||
CRONICLE_URL=http://cronicle:3012
|
||||
CRONICLE_API_KEY=
|
||||
# Internal URL raggr is reachable at from Cronicle — update after a color swap
|
||||
RAGGR_INTERNAL_URL=http://raggr-green:8080
|
||||
|
||||
# SimbaKit / PetKit Configuration
|
||||
# PetKit account credentials (used by SimbaKit to poll device data)
|
||||
|
||||
@@ -63,6 +63,7 @@ x-raggr-common: &raggr-common
|
||||
- CRON_SECRET=${CRON_SECRET}
|
||||
- CRONICLE_URL=${CRONICLE_URL:-http://cronicle:3012}
|
||||
- CRONICLE_API_KEY=${CRONICLE_API_KEY}
|
||||
- RAGGR_INTERNAL_URL=${RAGGR_INTERNAL_URL:-http://raggr-green:8080}
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
|
||||
+17
-14
@@ -47,7 +47,7 @@ async def _get_first_category_id() -> str:
|
||||
return rows[0]["id"]
|
||||
|
||||
|
||||
async def _create_event(title: str, script: str, category_id: str) -> str:
|
||||
async def _create_event(title: str, url: str, headers: str, category_id: str) -> str:
|
||||
async with httpx.AsyncClient() as client:
|
||||
resp = await client.post(
|
||||
f"{_base_url()}/api/app/create_event/v1",
|
||||
@@ -55,11 +55,17 @@ async def _create_event(title: str, script: str, category_id: str) -> str:
|
||||
"api_key": _api_key(),
|
||||
"title": title,
|
||||
"enabled": 1,
|
||||
"plugin": "shellplug",
|
||||
"plugin": "urlplug",
|
||||
"target": "allgrp",
|
||||
"category": category_id,
|
||||
"timing": {},
|
||||
"params": {"script": script},
|
||||
# Every minute: all 60 minutes explicitly (Cronicle {} defaults to hourly)
|
||||
"timing": {"minutes": list(range(60))},
|
||||
"params": {
|
||||
"method": "post",
|
||||
"url": url,
|
||||
"headers": headers,
|
||||
"data": "",
|
||||
},
|
||||
"notes": "Auto-registered by raggr on startup",
|
||||
},
|
||||
timeout=10,
|
||||
@@ -81,6 +87,7 @@ async def ensure_cronicle_events() -> None:
|
||||
return
|
||||
|
||||
cron_secret = os.environ.get("CRON_SECRET", "")
|
||||
raggr_url = os.environ.get("RAGGR_INTERNAL_URL", "http://raggr-green:8080")
|
||||
|
||||
try:
|
||||
events = await _get_events()
|
||||
@@ -88,17 +95,13 @@ async def ensure_cronicle_events() -> None:
|
||||
logger.info("Cronicle: '%s' already registered", _SCHEDULED_MESSAGES_TITLE)
|
||||
return
|
||||
|
||||
trigger_cmd = (
|
||||
"curl -sf -X POST {url}/api/scheduled-messages/trigger"
|
||||
f" -H 'X-Cron-Secret: {cron_secret}'"
|
||||
)
|
||||
script = (
|
||||
trigger_cmd.format(url="http://raggr-green:8080")
|
||||
+ " || "
|
||||
+ trigger_cmd.format(url="http://raggr-blue:8080")
|
||||
)
|
||||
category_id = await _get_first_category_id()
|
||||
event_id = await _create_event(_SCHEDULED_MESSAGES_TITLE, script, category_id)
|
||||
event_id = await _create_event(
|
||||
title=_SCHEDULED_MESSAGES_TITLE,
|
||||
url=f"{raggr_url}/api/scheduled-messages/trigger",
|
||||
headers=f"X-Cron-Secret: {cron_secret}",
|
||||
category_id=category_id,
|
||||
)
|
||||
logger.info(
|
||||
"Cronicle: created '%s' (id=%s)", _SCHEDULED_MESSAGES_TITLE, event_id
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user