commit
57aca355cd
6
app.js
6
app.js
|
@ -87,6 +87,12 @@ app.post(routes.remove, function(req, res) {
|
||||||
res.end();
|
res.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// run a job
|
||||||
|
app.post(routes.run, function(req, res) {
|
||||||
|
crontab.runjob(req.body._id);
|
||||||
|
res.end();
|
||||||
|
});
|
||||||
|
|
||||||
// set crontab. Needs env_vars to be passed
|
// set crontab. Needs env_vars to be passed
|
||||||
app.get(routes.crontab, function(req, res, next) {
|
app.get(routes.crontab, function(req, res, next) {
|
||||||
crontab.set_crontab(req.query.env_vars, function(err) {
|
crontab.set_crontab(req.query.env_vars, function(err) {
|
||||||
|
|
|
@ -74,6 +74,15 @@ exports.get_crontab = function(_id, callback) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.runjob = function(_id, callback) {
|
||||||
|
db.find({_id: _id}).exec(function(err, docs){
|
||||||
|
var res = docs[0];
|
||||||
|
exec(res.command, function(error, stdout, stderr){
|
||||||
|
console.log(stdout);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Set actual crontab file from the db
|
// Set actual crontab file from the db
|
||||||
exports.set_crontab = function(env_vars, callback){
|
exports.set_crontab = function(env_vars, callback){
|
||||||
exports.crontabs( function(tabs){
|
exports.crontabs( function(tabs){
|
||||||
|
|
|
@ -55,6 +55,15 @@ function startJob(_id){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function runJob(_id){
|
||||||
|
messageBox("<p> Do you want to run this Job? </p>", "Confirm run job", null, null, function(){
|
||||||
|
$.post(routes.run, {_id: _id}, function(){
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function setCrontab(){
|
function setCrontab(){
|
||||||
messageBox("<p> Do you want to set the crontab file? </p>", "Confirm crontab setup", null, null, function(){
|
messageBox("<p> Do you want to set the crontab file? </p>", "Confirm crontab setup", null, null, function(){
|
||||||
$.get(routes.crontab, { "env_vars": $("#env_vars").val() }, function(){
|
$.get(routes.crontab, { "env_vars": $("#env_vars").val() }, function(){
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
exports.routes = {
|
exports.routes = {
|
||||||
"root" : "/",
|
"root" : "/",
|
||||||
"save" : "/save",
|
"save" : "/save",
|
||||||
|
"run" : "/runjob",
|
||||||
"crontab" : "/crontab",
|
"crontab" : "/crontab",
|
||||||
"stop" : "/stop",
|
"stop" : "/stop",
|
||||||
"start" : "/start",
|
"start" : "/start",
|
||||||
|
|
|
@ -84,6 +84,7 @@
|
||||||
<% if (crontab.logging && crontab.logging != "false") {%>
|
<% if (crontab.logging && crontab.logging != "false") {%>
|
||||||
<a class="btn btn-primary" data-toggle="tooltip" data-placement="left" title="See Log" href="<%= JSON.parse(routes).logger + '?id=' + crontab._id %>" target="_blank"><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span></a>
|
<a class="btn btn-primary" data-toggle="tooltip" data-placement="left" title="See Log" href="<%= JSON.parse(routes).logger + '?id=' + crontab._id %>" target="_blank"><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span></a>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<a class="btn btn-info" onclick="runJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-open" aria-hidden="true"></span> Run</a>
|
||||||
<a class="btn btn-primary" onclick="editJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span> Edit</a>
|
<a class="btn btn-primary" onclick="editJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span> Edit</a>
|
||||||
<a class="btn btn-info" onclick="stopJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-stop" aria-hidden="true"></span> Stop</a>
|
<a class="btn btn-info" onclick="stopJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-stop" aria-hidden="true"></span> Stop</a>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
|
|
Loading…
Reference in New Issue