Permalink
Browse files

Adding upstart job and fixing file size

  • Loading branch information...
1 parent 2e472ec commit d9dcc05e98c8d25b0ff3dbd1486e957edb66f539 Frank LoVecchio committed Jan 4, 2012
Showing with 19 additions and 6 deletions.
  1. +17 −3 bin/node-monitor.sh
  2. +2 −3 plugins/filesize.js
View
20 bin/node-monitor.sh
@@ -6,10 +6,11 @@ case "$1" in
'start')
echo "Starting node-monitor"
- cd ~/node-monitor/run
-
+ #cd ~/node-monitor/run
#node client.js > /dev/null 2>&1 &
- node client.js ec2=true debug=false console=false cloudwatch=true &
+ #node client.js ec2=true debug=false console=false cloudwatch=true &
+
+ start node-monitor
;;
'stop')
@@ -58,6 +59,19 @@ case "$1" in
chmod a+x ~/node-monitor/bin/ec2-metadata
cd ~/node-monitor
npm link
+
+ cat >> /etc/init/node-monitor.conf <<EOF
+ description "node-monitor"
+ author "franklovecchio"
+
+ start on (local-filesystems and net-device-up IFACE=eth0)
+ stop on shutdown
+
+ respawn
+
+ exec sudo -u root sh -c "cd /home/ubuntu/node-monitor/run && /usr/local/bin/node /home/ubuntu/node-monitor/run/client.js ec2=true debug=false console=true cloudwatch=true>> /var/log/node-monitor.log 2>&1"
+
+ EOF
;;
'install-centos')
View
5 plugins/filesize.js
@@ -45,7 +45,7 @@ this.poll = function (constants, utilities, logger, callback) {
for (i = 0; i < splitBuffer.length; i++) {
var aFile = [];
aFile = splitBuffer[i].split('=');
- if (!self.utilities.isEmpty(aFile[0])) {
+ if (aFile[0] != '' || aFile[0] != undefined) {
self.logger.write(self.constants.levels.INFO, 'Checking file: ' + aFile[0] + ' with limit: ' + aFile[1]);
files.push(new fileCheck(aFile[0], Number(aFile[1])));
}
@@ -61,8 +61,6 @@ this.poll = function (constants, utilities, logger, callback) {
return;
}
if (Number(stat.size) > Number(file.sizeLimit)) {
- callback(Plugin.name, 'FileSize-' + file, 'Kilobytes', stat.size, Plugin.format(
- file.name, stat.size));
self.logger.write(self.constants.levels.INFO, 'Emptying file, it exceeds limit');
fs.writeFile(file, '', function (error) {
if (error) self.logger.write(Module.constants.levels.WARNING, 'Error emptying file: ' + error);
@@ -71,6 +69,7 @@ this.poll = function (constants, utilities, logger, callback) {
} else {
self.logger.write(self.constants.levels.INFO, 'Filesize is OK');
}
+ callback(Plugin.name, 'FileSize-' + file, 'Kilobytes', stat.size, Plugin.format(file.name, stat.size));
});
}
});

0 comments on commit d9dcc05

Please sign in to comment.