Reputation: 595
Is there anyway to schedule sails lift ? (every 12 hours for example sails restarts) The reason why I am trying to do this, is because I keep loosing connection to the remote database. Thank you
Upvotes: 1
Views: 159
Reputation: 2986
Maybe you should try to fix the issue with connection to database ? :)
About your question, you can modify app.js
file with following contents:
var Sails = require('sails');
var cron = require('node-cron');
var sails;
function startServer() {
if (sails) {
sails.lower(_onServerLower);
} else {
Sails.lift({}, _onServerStarted);
}
}
function _onServerStarted(error, server) {
sails = server;
}
function _onServerLower(error) {
sails = null;
startServer();
}
new cron.CronJob('* * */12 * * *', startServer, null, true);
But, really. Maybe you should fix issue with connection ? :)
Upvotes: 5