* Added --no-start to tools/anvil-daemon to allow for updating just the jobs.json file. Fixed a bug where a comma was missing when 2+ jobs were written to the JSON file as well.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 6 years ago
parent 15994727fb
commit 12073ffa08
  1. 4
      html/skins/alteeve/jobs.js
  2. 6
      tools/anvil-daemon

@ -4,10 +4,12 @@ $.ajaxSetup({
// TODO: Loop through jobs found on HTML and hide and divs that aren't found in jobs.json. // TODO: Loop through jobs found on HTML and hide and divs that aren't found in jobs.json.
$(function() { $(function() {
var say_status_waiting = $('input#status_waiting').val(); var say_status_waiting = $('input#status_waiting').val();
//console.log('say_status_waiting: ['+say_status_waiting+']');
if($("#running_jobs").length) { if($("#running_jobs").length) {
//console.log('Looking for running jobs.'); //console.log('Looking for running jobs.');
setInterval(function() { setInterval(function() {
$.getJSON('/status/jobs.json', { get_param: 'value' }, function(data) { $.getJSON('/status/jobs.json', { get_param: 'value' }, function(data) {
//console.log('"/status/jobs.json" read.');
$.each(data.jobs, function(index, element) { $.each(data.jobs, function(index, element) {
var progress = element.job_progress; var progress = element.job_progress;
@ -40,6 +42,6 @@ $(function() {
} }
else else
{ {
//console.log('Jobs status not loaded.'); //console.log('"running_jobs" div not found.');
} }
}); });

@ -60,6 +60,7 @@ if (not $anvil->data->{sys}{database}{connections})
# Read switches # Read switches
$anvil->data->{switches}{'run-once'} = ""; $anvil->data->{switches}{'run-once'} = "";
$anvil->data->{switches}{'main-loop-only'} = ""; $anvil->data->{switches}{'main-loop-only'} = "";
$anvil->data->{switches}{'no-start'} = 0;
$anvil->Get->switches; $anvil->Get->switches;
# There are some things we only want to run on (re)start and don't need to always run. # There are some things we only want to run on (re)start and don't need to always run.
@ -362,13 +363,13 @@ sub run_jobs
updated_seconds_ago => $updated_seconds_ago, updated_seconds_ago => $updated_seconds_ago,
}); });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { json_string => $json_string }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { json_string => $json_string }});
$jobs_file .= $json_string."\n"; $jobs_file .= $json_string.",\n";
# If the job is done, move on. # If the job is done, move on.
next if $job_progress eq "100"; next if $job_progress eq "100";
# If the job is not running, start it. # If the job is not running, start it.
if (not $job_picked_up_by) if ((not $job_picked_up_by) && (not $anvil->data->{switches}{'no-start'}))
{ {
# Start the job, appending '--job-uuid' to the command. # Start the job, appending '--job-uuid' to the command.
$anvil->data->{jobs}{handles}{$job_uuid} = $anvil->System->call({ $anvil->data->{jobs}{handles}{$job_uuid} = $anvil->System->call({
@ -389,6 +390,7 @@ sub run_jobs
} }
# Close the jobs file. # Close the jobs file.
$jobs_file =~ s/,\n$/\n/ms;
$jobs_file .= "]}\n"; $jobs_file .= "]}\n";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { jobs_file => $jobs_file }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { jobs_file => $jobs_file }});

Loading…
Cancel
Save