Ability to view stdout added

pull/111/head
alse 5 years ago
parent 9d5238b0aa
commit ee3aad8a2f

@ -184,13 +184,23 @@ app.get(routes.import_crontab, function(req, res) {
res.end();
});
// get the log file a given job. id passed as query param
app.get(routes.logger, function(req, res) {
_file = crontab.log_folder +"/"+req.query.id+".log";
if (fs.existsSync(_file))
res.sendFile(_file);
function sendLog(path, req, res) {
if (fs.existsSync(path))
res.sendFile(path);
else
res.end("No errors logged yet");
}
// get the log file a given job. id passed as query param
app.get(routes.logger, function(req, res) {
let _file = crontab.log_folder + "/" + req.query.id + ".log";
sendLog(_file, req, res);
});
// get the log file a given job. id passed as query param
app.get(routes.stdout, function(req, res) {
let _file = crontab.log_folder + "/" + req.query.id + ".stdout.log";
sendLog(_file, req, res);
});
// error handler

@ -95,6 +95,7 @@ exports.set_crontab = function(env_vars, callback){
let stderr = path.join(cronPath, tab._id + ".stderr");
let stdout = path.join(cronPath, tab._id + ".stdout");
let log_file = path.join(exports.log_folder, tab._id + ".log");
let log_file_stdout = path.join(exports.log_folder, tab._id + ".stdout.log");
if(tab.command[tab.command.length-1] != ";") // add semicolon
tab.command +=";";
@ -106,6 +107,11 @@ exports.set_crontab = function(env_vars, callback){
"; then date >> \"" + log_file + "\"" +
"; cat " + stderr + " >> \"" + log_file + "\"" +
"; fi";
crontab_string += "; if test -f " + stdout +
"; then date >> \"" + log_file_stdout + "\"" +
"; cat " + stdout + " >> \"" + log_file_stdout + "\"" +
"; fi";
}
if (tab.hook) {

@ -14,4 +14,5 @@ exports.routes = {
"import": "/import", // this is import from database
"import_crontab": "/import_crontab", // this is from existing crontab
"logger": "/logger",
"stdout": "/stdout",
};

@ -82,7 +82,8 @@
<!-- controls based on crontab state -->
<% if (!crontab.stopped) { %>
<% 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 btn-danger" data-toggle="tooltip" data-placement="left" title="stderr" 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="stdout" href="<%= JSON.parse(routes).stdout + '?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-play" 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>

Loading…
Cancel
Save