-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathip_deamon.php
More file actions
69 lines (51 loc) · 1.71 KB
/
Copy pathip_deamon.php
File metadata and controls
69 lines (51 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
// version 1.3
$api_url = 'http://dashboard.miningcontrolpanel.com';
include('/mcp/global_vars.php');
include('/mcp/functions.php');
// console_output("Building deamon. May take up to 30 seconds.");
// sleep(30);
$runs = $argv[1];
$forced_lag = $argv[2];
$forced_lag_counter = 0;
$miners_raw = file_get_contents($api_url."/api/?key=".$config['api_key']."&c=site_miners");
$miners = json_decode($miners_raw, true);
if(isset($miners['miners']))
{
foreach($miners['miners'] as $miner)
{
$miner_ids[] = $miner['id'];
}
$count = count($miner_ids);
console_output("Polling " . $count . " miners.");
for ($i=0; $i<$runs; $i++) {
console_output("Spawning children.");
for ($j=0; $j<$count; $j++) {
// echo "Checking Miner: ".$miner_ids[$j]."\n";
$pipe[$j] = popen("php -q /mcp/deamon_update_miner_stats.php -p='".$miner_ids[$j]."'", 'w');
if(isset($argv[2]))
{
$forced_lag_counter = $forced_lag_counter + 1;
// console_output($forced_lag_counter);
if($forced_lag_counter == $forced_lag)
{
// console_output("forced_lag_counter = " . $forced_lag_counter);
sleep(1);
// console_output("done sleeping");
$forced_lag_counter = 0;
}
}
}
// console_output("Killing children.");
// wait for them to finish
for ($j=0; $j<$count; ++$j) {
pclose($pipe[$j]);
}
// console_output("Sleeping.");
// sleep(1);
}
}else{
console_output("No ASIC miners.");
}
exit();
?>