Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. "use strict";
  2. require('heapdump');
  3.  
  4. setInterval(function () {
  5. global.gc();
  6. var heapUsed = process.memoryUsage().heapUsed;
  7. console.log("Program is using " + heapUsed + " bytes of Heap.")
  8. // process.kill(process.pid, 'SIGUSR2');
  9. }, 1000);
  10.  
  11. var home_url='http://domain.com/';
  12.  
  13. var mysql = require("mysql");
  14. var request = require('request');
  15. var timer1_i = 100, timer2_i = 300, timer3_i = 200;
  16.  
  17. // First you need to create a connection to the db
  18. var con = mysql.createConnection({
  19. host: 'localhost',
  20. user: 'root',
  21. password: '123',
  22. database: 'op',
  23. });
  24.  
  25. con.connect(function(err){
  26. if(err){
  27. return;
  28. }
  29. });
  30.  
  31. timer1();
  32. timer2();
  33. timer3();
  34.  
  35. function timer1() {
  36. setTimeout(function() {
  37. var time=Math.round(new Date().getTime()/1000);
  38. var queryString = 'SELECT id FROM options where finished=0 and end_timestamp < ' +con.escape(time);
  39.  
  40. con.query(queryString,function(err,rows){
  41. if(err) throw err;
  42.  
  43. request.post({
  44. headers: {'content-type' : 'application/x-www-form-urlencoded'},
  45. url: home_url+'finish_option.php',
  46. // body: "data="+JSON.stringify(rows),
  47. json: true
  48. }, function(error, response, body){
  49. });
  50.  
  51. });
  52. timer1();
  53. }, timer1_i);
  54. }
  55.  
  56. function timer2() {
  57. setTimeout(function() {
  58. var time=Math.round(new Date().getTime()/1000);
  59. var queryString = 'SELECT id FROM options where finished=1 and paid=1 and paid_finished=0';
  60.  
  61. con.query(queryString,function(err,rows){
  62. if(err) throw err;
  63.  
  64. request.post({
  65. headers: {'content-type' : 'application/x-www-form-urlencoded'},
  66. url: home_url+'payment.php',
  67. body: "data="+JSON.stringify(rows),
  68. json: true
  69. }, function(error, response, body){
  70. });
  71.  
  72. });
  73.  
  74. }, timer2_i);
  75. }
  76.  
  77. function timer3() {
  78. setTimeout(function() {
  79. var time=Math.round(new Date().getTime()/1000);
  80.  
  81. request.post({
  82. headers: {'content-type' : 'application/x-www-form-urlencoded'},
  83. url: home_url+'get_rate.php',
  84. json: true
  85. }, function(error, response, body){
  86. });
  87. }, timer3_i);
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement