mirror of
https://github.com/Haidra-Org/AI-Horde.git
synced 2026-11-06 05:17:31 +00:00
* docs: readme.md introduction; register info rework My hope is that a more non-technical opening will help explain the project better to a wider audience of people. Additionally, I reworked the registration section to hopefully be clearer at a glance without having to parse multiple paragraphs of prose. * chore: add tazlin's email for license notices * docs: rewrites, links to expanded docs; md linting fixes * docs: add links to defs/detailed explanations * docs: fix typo * docs/style: fix formatting typo * docs: add info about kudos econ. on discord * docs: fix typo * docs: link to `haidra-assets/docs`
40 lines
1.4 KiB
PL/PgSQL
40 lines
1.4 KiB
PL/PgSQL
-- SPDX-FileCopyrightText: 2024 Tazlin <tazlin.on.github@gmail.com>
|
|
--
|
|
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
CREATE EXTENSION IF NOT EXISTS pg_cron;
|
|
|
|
CREATE OR REPLACE PROCEDURE schedule_cron_job(
|
|
p_schedule TEXT,
|
|
p_stored_procedure TEXT
|
|
)
|
|
LANGUAGE plpgsql
|
|
AS $$
|
|
DECLARE
|
|
existing_schedule TEXT;
|
|
existing_jobid INT;
|
|
BEGIN
|
|
SET search_path TO cron, public;
|
|
|
|
-- Get the existing schedule and jobid for the stored procedure
|
|
SELECT schedule, jobid
|
|
INTO existing_schedule, existing_jobid
|
|
FROM cron.job
|
|
WHERE command = format($CRON$ CALL %s(); $CRON$, p_stored_procedure);
|
|
|
|
-- If the job exists and the schedules don't match, update it
|
|
IF FOUND AND existing_schedule <> p_schedule THEN
|
|
PERFORM cron.unschedule(existing_jobid);
|
|
PERFORM cron.schedule(p_schedule, format($CRON$ CALL %s(); $CRON$, p_stored_procedure));
|
|
RAISE NOTICE 'Cron job schedule updated successfully for stored procedure: %', p_stored_procedure;
|
|
-- If the job doesn't exist, schedule it
|
|
ELSIF NOT FOUND THEN
|
|
PERFORM cron.schedule(p_schedule, format($CRON$ CALL %s(); $CRON$, p_stored_procedure));
|
|
RAISE NOTICE 'Cron job scheduled successfully for stored procedure: %', p_stored_procedure;
|
|
ELSE
|
|
RAISE NOTICE 'Cron job already exists with the same schedule for stored procedure: %. Skipping scheduling.', p_stored_procedure;
|
|
END IF;
|
|
END $$;
|
|
|
|
UPDATE cron.job SET nodename = '';
|