public function actionRunExchange() { $id = getiparam('id'); $balance = getdbo('db_balances', $id); if ($balance) { switch ($balance->name) { case 'cryptsy': doCryptsyTrading(true); updateCryptsyMarkets(); break; case 'bittrex': doBittrexTrading(true); updateBittrexMarkets(); break; case 'c-cex': doCCexTrading(true); updateCCexMarkets(); break; case 'yobit': doYobitTrading(true); updateYobitMarkets(); break; case 'bleutrade': doBleutradeTrading(true); updateBleutradeMarkets(); break; case 'poloniex': doPoloniexTrading(true); updatePoloniexMarkets(); break; } } debuglog("runexchange done"); $this->redirect("/site/common"); }
public function actionRun() { // debuglog(__METHOD__); set_time_limit(0); // BackendRunCoinActions(); $state = memcache_get($this->memcache->memcache, 'cronjob_main_state'); if (!$state) { $state = 0; } memcache_set($this->memcache->memcache, 'cronjob_main_state', $state + 1); memcache_set($this->memcache->memcache, "cronjob_main_state_{$state}", 1); switch ($state) { case 0: updateRawcoins(); $a = json_decode(fetch_url("https://www.bitstamp.net/api/ticker/")); if ($a && isset($a->last)) { $mining = getdbosql('db_mining'); $mining->usdbtc = $a->last; $mining->save(); } break; case 1: if (!YAAMP_PRODUCTION) { break; } doBittrexTrading(); doCryptsyTrading(); doBleutradeTrading(); doPoloniexTrading(); doYobitTrading(); doCCexTrading(); break; case 2: BackendPricesUpdate(); break; case 3: BackendBlocksUpdate(); break; case 4: TradingSellCoins(); break; case 5: BackendBlockFind2(); break; default: memcache_set($this->memcache->memcache, 'cronjob_main_state', 0); BackendQuickClean(); // sleep(120); $t = memcache_get($this->memcache->memcache, "cronjob_main_start_time"); $n = time(); memcache_set($this->memcache->memcache, "cronjob_main_time", $n - $t); memcache_set($this->memcache->memcache, "cronjob_main_start_time", $n); } debuglog(__METHOD__ . " {$state}"); memcache_set($this->memcache->memcache, "cronjob_main_state_{$state}", 0); memcache_set($this->memcache->memcache, "cronjob_main_time_start", time()); if (!YAAMP_PRODUCTION) { return; } /////////////////////////////////////////////////////////////////// $mining = getdbosql('db_mining'); if ($mining->last_payout + YAAMP_PAYMENTS_FREQ > time()) { return; } debuglog("--------------------------------------------------------"); $mining->last_payout = time(); $mining->save(); memcache_set($this->memcache->memcache, 'apache_locked', true); system("service nginx stop"); sleep(10); BackendDoBackup(); memcache_set($this->memcache->memcache, 'apache_locked', false); BackendPayments(); BackendCleanDatabase(); // BackendOptimizeTables(); debuglog('payments sequence done'); }