-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scheduler Action #8
Comments
In the backend a call of this form will be made each time a job is executed: async with httpx.AsyncClient() as client:
resp = await client.get( # action can be any HTTP verb (GET, PUT, POST, etc) set in the job config
url, # from the job config
headers, # from the job config
)
save_job_execution(resp.status_code, resp.text()) |
@motorina0 OK. I think the directions are clear. The python-crontabs module would store the X-API-Key values as environment variables in the crontab file, so each individual job will have its own set of env vars. Assuming there is no need for global env vars, I'll remove the Global Environment variables box that is currently at the bottom of the extension right now. Please do let me know if incorrect! thanks. |
Regarding running jobs:
Adapting a simple example from here: from crontab import CronTab
cron = CronTab(user='username')
job = cron.new(command='python lnbits/utils/cron-job.py') # pass the job_id param somehow
job.minute.every(1)
cron.write()
# imports go here
# extract job_id param
# query DB for job
async with httpx.AsyncClient() as client:
resp = await client.get( # action can be any HTTP verb (GET, PUT, POST, etc) set in the job config
url, # from the job config
headers, # from the job config
)
save_job_execution(resp.status_code, resp.text()) Note:
|
|
|
OK I am testing this with both Ubuntu and OSX. Will try to have everything working with latest 0.11 this weekend. (this week has been a bit busy) |
Regarding - I have this script running when the cron job is triggered but is does not have the LNBits environment, I put it in as an env variable in .env but if you have a better way of accessing it, please suggest! Line 20 in 2ceb03e
extension updated to allow for LNBits v0.11 but still need to do more testing. |
HOST=127.0.0.1
PORT=5000
|
yes I know that the HOST/PORT is in the LNBits .env, but that cron script unfortunately runs outside of the LNBits environment as its called by system crontab which doesn't inherit the LNBits environment. I can pass the HOST/PORT in, just like the job ID and adminKey is passed in right now (this is testnet example). Perhaps this is better way to do it. Ok I will test and get back to you. Thanks @motorina0 |
OK I fixed the above, made a release. It should be working with basic functionality now, validation can improve but please have a look. https://github.com/bitkarrot/scheduler/releases/tag/v0.0.9, @motorina0 |
tested with sqlitedb only so far, no postgres |
rmdir
) for now (keep it simple(r))Call Config:
Call Body
The text was updated successfully, but these errors were encountered: