new:dev:support run the jobs manually
parent
a84171ac11
commit
bb7f57e903
6
app.js
6
app.js
|
@ -87,6 +87,12 @@ app.post(routes.remove, function(req, res) {
|
|||
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
|
||||
app.get(routes.crontab, function(req, res, next) {
|
||||
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
|
||||
exports.set_crontab = function(env_vars, callback){
|
||||
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(){
|
||||
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(){
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
exports.routes = {
|
||||
"root" : "/",
|
||||
"save" : "/save",
|
||||
"run" : "/runjob",
|
||||
"crontab" : "/crontab",
|
||||
"stop" : "/stop",
|
||||
"start" : "/start",
|
||||
|
|
|
@ -84,6 +84,7 @@
|
|||
<% 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-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-info" onclick="stopJob('<%= crontab._id %>')"><span class="glyphicon glyphicon-stop" aria-hidden="true"></span> Stop</a>
|
||||
<% } else { %>
|
||||
|
|
Loading…
Reference in New Issue