crashed.js 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. ;(function(){ try {
  2. var fs = require('fs'), logs = [], up = __dirname+'/../';
  3. fs.readdir(up, function(err, list){ try{
  4. var i = 0, f; while(f = list[i++]){
  5. if(0 === f.indexOf('isolate-') && '.log' === f.slice(-4)){ logs.push(f) }
  6. }
  7. logs = logs.sort();
  8. var i = 0, f, lf; while(f = list[i++]){
  9. if(0 <= f.indexOf('-v8-') && '.log' === f.slice(-4)){ lf = f }
  10. } f = lf;
  11. if(!f){ return }
  12. fs.rename(up+f, up+'v8.log', function(err,ok){
  13. var i = 0, f; while(f = logs[i++]){ fs.unlink(up+f, noop) }
  14. if(!process.env.EMAIL){ return } // ONLY EMAIL IF DEVELOPER OPTS IN!!!
  15. email(); // ONLY EMAIL IF DEVELOPER OPTS IN!!!
  16. });
  17. }catch(e){} });
  18. function noop(){};
  19. function email(){ try{
  20. if(!process.env.EMAIL){ return } // ONLY EMAIL IF DEVELOPER OPTS IN!!!
  21. var address = process.env.EMAIL || "mark@gun.eco";
  22. // you also have to specify your EMAIL_KEY gmail 2F' app's password (not reg) to send out.
  23. require('./email').send({
  24. text: "log attached",
  25. from: address,
  26. to: address,
  27. subject: "GUN V8 LOG",
  28. attachment:[{path: up+'v8.log', type:"text/plain", name:"v8.log"}]
  29. }, noop);
  30. }catch(e){} };
  31. }catch(e){}
  32. }());