Skip to content
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

Feature: Add jobs administration #37

Draft
wants to merge 3 commits into
base: development
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add cron jobs administration endpoints
syphax-bouazzouni committed Apr 15, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit e8b41921fafd3c4952c93bc1d2f560bd72d75ce3
32 changes: 20 additions & 12 deletions controllers/admin_controller.rb
Original file line number Diff line number Diff line change
@@ -9,18 +9,26 @@ class AdminController < ApplicationController
end
}

# TODO: remove this endpoint. It's termporary to test the update check functionality
# get "/latestversion" do
# iid = params["iid"]
# ver = params["version"]
#
# latest_ver_info = {
# update_version: "2.5RC3", #"2.6RC1",
# update_available: true,
# notes: "blah blah and more"
# }
# reply MultiJson.dump latest_ver_info
# end

get "/scheduled_jobs" do
reply MultiJson.dump scheduled_jobs_map
end

get "/scheduled_jobs/log" do
log_path = cron_daemon_options[:log_path]
stream_file(log_path)
end

get "/scheduled_jobs/:job/log" do
scheduled_jobs = scheduled_jobs_map
job_name = params["job"]
error 404, "You must provide a valid `job` to retrieve its log" unless scheduled_jobs.has_key?(job_name.to_sym)

log_dir_name = File.dirname(cron_daemon_options[:log_path])
log_file_name = "#{log_dir_name.chomp '/'}/scheduler-#{job_name.gsub '_', '-'}.log"

stream_file(log_file_name)
end

get "/update_info" do
um = NcboCron::Models::UpdateManager.new