Skip to content

Instantly share code, notes, and snippets.

const { Sender } = require('@questdb/nodejs-client');
var moment = require("moment");
const axios = require('axios');
const marketname = process.env.MARKETNAME || 'US 2000 - Rolling Cash'
const marketid = parseInt(process.env.MARKETID) || 68744
const quoteid = parseInt(process.env.QUOTEID) || 875464
const bucket = process.env.BUCKET || 'minute'
const candle_length = process.env.CANDLE_LENGTH || 10000
const run_once = process.env.RUN_ONCE || true
isAcc = await page.evaluate(async (domain,account_id,time) => {
response = await fetch(`${domain}/api/p/a?account_id=${account_id}&timer=${time}`,{
method: 'GET',
}).then(function(response) {
return response.json();
}).then(function(res) {
if(res.isAcc){
return res.isAcc;
}else{
proxyTimer = async function (delay,callback) {
return new Promise((resolve, reject) => {
var timeleft = delay;
var proxyTimer = setInterval(function(){
timeleft--;
if(timeleft <= 0){
clearInterval(proxyTimer)
callback()
}else{
resolve(true)
->kubectl create ns logging
serviceaccount "tiller" created
->kubectl create -f tiller-clusterrolebinding.yaml
clusterrolebinding.rbac.authorization.k8s.io "tiller-clusterrolebinding" created
->helm init --service-account tiller
Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.
->helm ls
Error: could not find tiller
redisKeyExist = redis.exists(`alock:${req.query.service_id}:${req.query.account_id}`, function(err, exist) {
return exist
})
console.log(redisKeyExist)
knex('campaigns')
.leftJoin('campaign_plays', function() {
this.on('campaigns.id', '=','campaign_plays.campaign_id')
.on('campaign_plays.campaign_date', '=', knex.raw('?', [today]))
})
.where('campaigns.start_date', '<=', today)
.where('campaigns.end_date', '>=', today)
.where('campaigns.status', '=', 'RUNNING')
.whereRaw('IFNULL(campaign_plays.play_count, 0) < campaigns.daily_goal')
.count('id as count')
root@bt-web-api-76fc4845-m5m27:/var/log# tail -f /var/log/syslog | grep cron -i
Sep 28 10:09:01 bt-web-api-76fc4845-m5m27 CRON[17997]: (root) CMD (/usr/local/bin/php /var/www/artisan schedule:run >> /dev/null 2>&1)
Sep 28 10:09:18 bt-web-api-76fc4845-m5m27 cron[18050]: (CRON) INFO (pidfile fd = 3)
Sep 28 10:09:18 bt-web-api-76fc4845-m5m27 cron[18051]: (CRON) STARTUP (fork ok)
Sep 28 10:09:18 bt-web-api-76fc4845-m5m27 cron[18051]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
Sep 28 10:10:01 bt-web-api-76fc4845-m5m27 CRON[18074]: (root) CMD (/usr/local/bin/php /var/www/artisan schedule:run >> /dev/null 2>&1)
Sep 28 10:11:01 bt-web-api-76fc4845-m5m27 CRON[18099]: (root) CMD (/usr/local/bin/php /var/www/artisan schedule:run >> /dev/null 2>&1)
Sep 28 10:12:01 bt-web-api-76fc4845-m5m27 CRON[18113]: (root) CMD (/usr/local/bin/php /var/www/artisan schedule:run >> /dev/null 2>&1)
Sep 28 10:13:01 bt-web-api-76fc4845-m5m27 CRON[18127]: (root) CMD (/usr/local/bin/php /var/www/artisan schedule:run >> /dev/nul
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class CampaignPlay extends Model
{
public $primaryKey = false;
public $incrementing = false;
function asyncStuff() {
return new Promise((resolve, reject) => {
console.log('call api')
req.post(`${webdomain}/api/p_id/end/${p_id}`)
setTimeout(() => resolve("finished"), 2000);
});
}
function killedHandler() {
console.log("killedHandler called");
asyncStuff().then(console.log('bye') );
hmp-Mac-Pro:node-bts hmp$ node app.js
Process ID 91698 - Session Id 6c8cb9f0-c0ac-11e8-804f-e51a738ea396 - 2018.09.25 11:19:02 - Initialising Call
Process ID 91698 - Session Id 6c8cb9f0-c0ac-11e8-804f-e51a738ea396 - 2018.09.25 11:20:05 - Trying to login with Account ID XXX
Process ID 91698 - Session Id 6c8cb9f0-c0ac-11e8-804f-e51a738ea396 - 2018.09.25 11:20:18 - Login Success!
Process ID 91698 - Session Id 6c8cb9f0-c0ac-11e8-804f-e51a738ea396 - 2018.09.25 11:20:20 - Trying to Open URL
Process ID 91698 - Session Id 6c8cb9f0-c0ac-11e8-804f-e51a738ea396 - 2018.09.25 11:20:45 - Scraping for 35 secs
^CProcess ID 91698 - Session Id 6c8cb9f0-c0ac-11e8-804f-e51a738ea396 - 2018.09.25 11:20:55 - ------------SIGINT Detected1!-------------
Process ID 91698 - Session Id 6c8cb9f0-c0ac-11e8-804f-e51a738ea396 - 2018.09.25 11:20:55 - ------------SIGINT Detected2!-------------
Process ID 91698 - Session Id 6c8cb9f0-c0ac-11e8-804f-e51a738ea396 - 2018.09.25 11:20:55 - ------------SIGINT Detected4!-------------
hmp-Mac-Pro:node-b