Cronicle API: create_event creates wrong timings
ContainerCat opened this issue · 3 comments
Summary
I am using a curl call to create an event. In the docs, I read the following: "Each property should be an array of numerical values. If omitted, it means the same as "all" in that category (i.e. asterisk * in Cron syntax)"
(https://github.com/jhuckaby/Cronicle/blob/master/docs/APIReference.md#event-timing-object). So i thought, if I do not give up my timings, it will run every minute of every hour of every day, etc.
Instead, it creates an on demand event.
I would like a way to create an * * * * * event without having to specify every "time"
Steps to reproduce the problem
Perform a curl call to the cronicle:
curl https://$CRONICLE_HOSTNAME/api/app/create_event/v1
-X POST
-H "Content-Type: application/json"
--data '{ "title": "'$CRON_IDENTIFIER'", "category": "general", "enabled": 1, "plugin": "shellplug", "target": "'$CRONICLE_HOSTNAME'", "session_id": "'$session_id'" }'
Your Setup
NA, but: Cronicle on Kubernetes with Loadbalancer
Operating system and version?
NA, but: Ubuntu 22.04.4
Node.js version?
v20.17.0
Cronicle software version?
Version 0.9.59
Are you using a multi-server setup, or just a single server?
single server
Are you using the filesystem as back-end storage, or S3/Couchbase?
filesystem
Can you reproduce the crash consistently?
NA
Log Excerpts
NA
Hi there!
I'm so sorry this tripped you up. There is a way to do it, but it's subtle, and I apologize for the confusion. Here is how to do it, and I will update the docs to cover this as well:
An "on demand" event has no timing
object at all. This is how the scheduler knows that an event should never run on any schedule, and can only be activated on-demand by user or API.
An event that should run every minute of every day of every month of every year, should have an empty timing
object, with no properties in it, e.g. "timing": {}
. So in your case, change your curl command to this:
curl https://$CRONICLE_HOSTNAME/api/app/create_event/v1 -X POST -H "Content-Type: application/json" --data '{ "title": "'$CRON_IDENTIFIER'", "category": "general", "enabled": 1, "plugin": "shellplug", "target": "'$CRONICLE_HOSTNAME'", "session_id": "'$session_id'", "timing": {} }'
I am updating the docs right now, to explain this properly.
Thank you for bringing this to my attention!
ah alright, thank you for coming back to me so fast. I tried and this worked!
btw: unrelated to this issue, but I am running Cronicle on Kubernetes and I found a simple solution to the cronicle with https behind a loadbalancer. I use haproxy but i think it should work with other proxies such as traefik/nginx as well.
Let me know if you're intrested. (and where I can clarify myself)
That's great! Please feel free to create a discussion topic about that: https://github.com/jhuckaby/Cronicle/discussions/new?category=show-and-tell
I'm sure others can benefit from it!