Skip to content

Commit

Permalink
Added optional dialog in Run Now for customizing the current time.
Browse files Browse the repository at this point in the history
Fixed bug in choose_date_time() which would not floor the seconds to 0.
Fixed bug where chain reaction mode could not be disabled after it was enabled on an event.
Misc fixes in README.md.
Bumped version to v0.1.5.
  • Loading branch information
jhuckaby committed Mar 6, 2016
1 parent 6625c11 commit 0021be4
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 11 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ This table lists all the upcoming scheduled jobs in the next 24 hours, and vario
| **Category** | The category to which the event is assigned. |
| **Plugin** | The Plugin which will be loaded to run the event. |
| **Target** | The server target (server group or individual server hostname) which will run the event. |
| **Scheduled Time** | When the event is scheduled to run (adjusted for your local timezone). |
| **Scheduled Time** | When the event is scheduled to run (in your local timezone unless otherwise specified). |
| **Countdown** | How much time remains until the event runs. |
| **Actions** | Click *Edit Event* to edit the event (see [Edit Event Tab](#edit-event-tab) below). |

Expand Down Expand Up @@ -796,7 +796,7 @@ For each event in the schedule, Cronicle keeps an internal clock called a "curso

So for example, if you needed to re-run a daily 4 AM report event, you can just edit the cursor clock and set it back to 3:59 AM. The cursor will catch up to the current time as quickly as it can, stopping only to run any scheduled events along the way. You can also use this feature to "jump" over a queue, if jobs have stacked up for an event. Just set the cursor clock to the current time, and the scheduler will resume jobs from that point onward.

The event clocks for the Time Machine are displayed and interpreted in the user's local timezone.
The event clock for the Time Machine is displayed and interpreted in the event's currently selected timezone.

#### Event Notification

Expand Down Expand Up @@ -934,6 +934,12 @@ CPU and RAM usage are measured every 10 seconds, by looking at the process spawn

Event notes are for your own internal use. They are displayed to users when editing an event, and in all e-mails regarding successful or failed jobs. For example, you could use this to describe the event to members of your team who may not be familiar, and possibly provide a link to other documentation. There is no character limit, so knock yourself out.

#### Run Now

To run an event immediately, click the **Run Now** button. This will run the current event regardless of its timing settings, and whether the event is enabled or disabled in the schedule. This is simply an on-demand job which is created and executed right away.

If you need to customize the internal clock for the job, hold Shift which clicking the Run Now button. This will bring up a dialog allowing you to set the date and time which the Plugin will see as the "current time", for your on-demand job only. It will not affect any other jobs or the event itself. This is useful for re-running past jobs with a Plugin that honors the `now` timestamp in the job data.

## Completed Jobs Tab

![Completed Jobs Screenshot](https://pixlcore.com/software/cronicle/screenshots/completed-jobs.png)
Expand Down
1 change: 1 addition & 0 deletions bin/test-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ stream.on('json', function(job) {

logger.debug(1, "This is a test debug log entry");
logger.debug(9, "Here is our job, delivered via JSONStream:", job);
logger.debug(9, "The current date/time for our job is: " + (new Date(job.now * 1000)).toString() );

// use some memory so we show up on the mem graph
var buf = new Buffer( 1024 * 1024 * Math.floor( 128 + (Math.random() * 128) ) );
Expand Down
1 change: 1 addition & 0 deletions htdocs/js/pages/Base.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ Class.subclass( Page, "Page.Base", {
margs.date( parseInt( $('#fe_dt_day').val() ) );
margs.hour( parseInt( $('#fe_dt_hour').val() ) );
margs.minute( parseInt( $('#fe_dt_minute').val() ) );
margs.second( 0 );

args.callback( margs.unix() );
}
Expand Down
37 changes: 30 additions & 7 deletions htdocs/js/pages/Schedule.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Class.subclass( Page.Base, "Page.Schedule", {
var self = this;
html += this.getBasicTable( this.events, cols, 'event', function(item, idx) {
var actions = [
'<span class="link" onMouseUp="$P().run_event('+idx+')"><b>Run</b></span>',
'<span class="link" onMouseUp="$P().run_event('+idx+',event)"><b>Run</b></span>',
'<span class="link" onMouseUp="$P().edit_event('+idx+')"><b>Edit</b></span>',
'<a href="#History?sub=event_stats&id='+item.id+'"><b>Stats</b></a>',
'<a href="#History?sub=event_history&id='+item.id+'"><b>History</b></a>',
Expand Down Expand Up @@ -186,11 +186,34 @@ Class.subclass( Page.Base, "Page.Schedule", {
} );
},

run_event: function(idx) {
run_event: function(event_idx, e) {
// run event ad-hoc style
var self = this;
var event = (event_idx == 'edit') ? this.event : this.events[event_idx];

if (e.shiftKey || e.ctrlKey || e.altKey) {
// allow use to select the "now" time
this.choose_date_time({
when: time_now(),
title: "Set Current Event Date/Time",
description: "Configure the internal date/time for the event to run immediately. This is the timestamp which the Plugin will see as the current time.",
button: "Run Now",
timezone: event.timezone || app.tz,

callback: function(new_epoch) {
self.run_event_now( event_idx, new_epoch );
}
});
}
else this.run_event_now(event_idx);
},

run_event_now: function(idx, now) {
// run event ad-hoc style
var event = (idx == 'edit') ? this.event : this.events[idx];
if (!now) now = time_now();

app.api.post( 'app/run_event', event, function(resp) {
app.api.post( 'app/run_event', merge_objects( event, { now: now } ), function(resp) {
var msg = '';
if (resp.ids.length > 1) {
// multiple jobs (multiplex)
Expand Down Expand Up @@ -425,7 +448,7 @@ Class.subclass( Page.Base, "Page.Schedule", {

// run
html += '<td width="40">&nbsp;</td>';
html += '<td><div class="button" style="width:110px; font-weight:normal;" onMouseUp="$P().run_event(\'edit\')">Run Now</div></td>';
html += '<td><div class="button" style="width:110px; font-weight:normal;" onMouseUp="$P().run_event(\'edit\',event)">Run Now</div></td>';

// save
html += '<td width="40">&nbsp;</td>';
Expand Down Expand Up @@ -963,7 +986,7 @@ Class.subclass( Page.Base, "Page.Schedule", {
if ($('#fe_ee_rc_enabled').is(':checked')) {
var epoch = (new Date( $('#fe_ee_rc_time').val() ).getTime()) / 1000;

$P().choose_date_time({
this.choose_date_time({
when: epoch,
title: "Set Event Clock",
timezone: this.event.timezone || app.tz,
Expand Down Expand Up @@ -1422,7 +1445,7 @@ Class.subclass( Page.Base, "Page.Schedule", {
if (isNaN(event.stagger)) return app.badField('fe_ee_stagger', "Please enter a number of seconds to stagger by.");
}
else {
delete event.stagger;
event.stagger = 0;
}

// plugin
Expand Down Expand Up @@ -1482,7 +1505,7 @@ Class.subclass( Page.Base, "Page.Schedule", {
event.chain = $('#fe_ee_chain').val();
}
else {
delete event.chain;
event.chain = "";
}

// cursor reset
Expand Down
2 changes: 1 addition & 1 deletion lib/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ module.exports = Class.create({
}

// chain reaction (only on success)
if (job.chain && (job.code == 0)) {
if (job.chain && job.chain.length && (job.code == 0)) {
this.chainReaction( job );
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Cronicle",
"version": "0.1.4",
"version": "0.1.5",
"description": "A simple, distributed task scheduler and runner with a web based UI.",
"author": "Joseph Huckaby <jhuckaby@gmail.com>",
"homepage": "https://github.com/jhuckaby/Cronicle",
Expand Down

0 comments on commit 0021be4

Please sign in to comment.