Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "use strict";
- require('heapdump');
- setInterval(function () {
- global.gc();
- var heapUsed = process.memoryUsage().heapUsed;
- console.log("Program is using " + heapUsed + " bytes of Heap.")
- // process.kill(process.pid, 'SIGUSR2');
- }, 1000);
- var home_url='http://domain.com/';
- var mysql = require("mysql");
- var request = require('request');
- var timer1_i = 100, timer2_i = 300, timer3_i = 200;
- // First you need to create a connection to the db
- var con = mysql.createConnection({
- host: 'localhost',
- user: 'root',
- password: '123',
- database: 'op',
- });
- con.connect(function(err){
- if(err){
- return;
- }
- });
- timer1();
- timer2();
- timer3();
- function timer1() {
- setTimeout(function() {
- var time=Math.round(new Date().getTime()/1000);
- var queryString = 'SELECT id FROM options where finished=0 and end_timestamp < ' +con.escape(time);
- con.query(queryString,function(err,rows){
- if(err) throw err;
- request.post({
- headers: {'content-type' : 'application/x-www-form-urlencoded'},
- url: home_url+'finish_option.php',
- // body: "data="+JSON.stringify(rows),
- json: true
- }, function(error, response, body){
- });
- });
- timer1();
- }, timer1_i);
- }
- function timer2() {
- setTimeout(function() {
- var time=Math.round(new Date().getTime()/1000);
- var queryString = 'SELECT id FROM options where finished=1 and paid=1 and paid_finished=0';
- con.query(queryString,function(err,rows){
- if(err) throw err;
- request.post({
- headers: {'content-type' : 'application/x-www-form-urlencoded'},
- url: home_url+'payment.php',
- body: "data="+JSON.stringify(rows),
- json: true
- }, function(error, response, body){
- });
- });
- }, timer2_i);
- }
- function timer3() {
- setTimeout(function() {
- var time=Math.round(new Date().getTime()/1000);
- request.post({
- headers: {'content-type' : 'application/x-www-form-urlencoded'},
- url: home_url+'get_rate.php',
- json: true
- }, function(error, response, body){
- });
- }, timer3_i);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement