mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
init
This commit is contained in:
parent
b5a202e155
commit
4d8a873075
4 changed files with 213 additions and 0 deletions
68
README.md
Normal file → Executable file
68
README.md
Normal file → Executable file
|
@ -1,2 +1,70 @@
|
|||
#yaamp
|
||||
|
||||
Required:
|
||||
|
||||
linux, mysql, php, web engine, memcached
|
||||
|
||||
Config for nginx:
|
||||
|
||||
location / {
|
||||
try_files $uri @rewrite;
|
||||
}
|
||||
|
||||
location @rewrite {
|
||||
rewrite ^/(.*)$ /index.php?r=$1;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
}
|
||||
|
||||
If you use apache, it should be something like:
|
||||
|
||||
RewriteEngine on
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^(.*) index.php?r=$1 [QSA]
|
||||
|
||||
The recommended install folder for the stratum engine is /var/stratum. Copy all the .conf files, run.sh, the stratum binary and the blocknotify binary to this folder.
|
||||
|
||||
Some scripts are expecting the web folder to be /var/web.
|
||||
|
||||
Add your exchange API keys in:
|
||||
|
||||
web/yaamp/core/exchange/*
|
||||
|
||||
Look at web/yaamp/core/trading/ there are a few place where there're hardcoded withdraw BTC address (cryptsy, bittrex and bleutrade).
|
||||
|
||||
Edit web/serverconfig.php
|
||||
|
||||
You need three backend shells (in screen) running these scripts:
|
||||
|
||||
web/main.sh
|
||||
web/loop2.sh
|
||||
web/block.sh
|
||||
|
||||
Start one stratum per algo using the run.sh script with the algo as parameter. For example, for x11:
|
||||
|
||||
run.sh x11
|
||||
|
||||
Edit each .conf file with proper values.
|
||||
|
||||
Look at rc.local, it starts all three backend shells and all stratum processes. Copy it to the /etc folder so that all screen shells are started at boot up.
|
||||
|
||||
All your coin's config files need to blocknotify their corresponding stratum using something like:
|
||||
|
||||
blocknotify=/var/stratum/blocknotify yaamp.com:port coinid %s
|
||||
|
||||
On the website, go to http://server.com/site/frottedessus to login as admin. You have to change it to something different in the code (web/yaamp/modules/site/SiteController.php).
|
||||
|
||||
There are logs generated in the /var/stratum folder and /var/log/stratum/debug.log for the php log.
|
||||
|
||||
More instructions coming as needed.
|
||||
|
||||
There a lot of unused code in the php branch. Lot come from other projects I worked on and I've been lazy to clean it up before to integrate it to yaamp. It's mostly based on the Yii framework which implements a lightweight MVC.
|
||||
|
||||
http://www.yiiframework.com/
|
||||
|
||||
|
||||
|
|
90
blocknotify/blocknotify.cpp
Executable file
90
blocknotify/blocknotify.cpp
Executable file
|
@ -0,0 +1,90 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
// program yaamp.com:port coinid blockhash
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if(argc < 4)
|
||||
{
|
||||
printf("usage: blocknotify server:port coinid blockhash\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *p = strchr(argv[1], ':');
|
||||
if(!p)
|
||||
{
|
||||
printf("usage: blocknotify server:port coinid blockhash\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int port = atoi(p+1);
|
||||
*p = 0;
|
||||
|
||||
int coinid = atoi(argv[2]);
|
||||
char blockhash[1024];
|
||||
strncpy(blockhash, argv[3], 1024);
|
||||
|
||||
int sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if(sock <= 0)
|
||||
{
|
||||
printf("error socket %s id %s\n", argv[1], argv[2]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct hostent *ent = gethostbyname(argv[1]);
|
||||
if(!ent)
|
||||
{
|
||||
printf("error gethostbyname %s id %s\n", argv[1], argv[2]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct sockaddr_in serv;
|
||||
|
||||
serv.sin_family = AF_INET;
|
||||
serv.sin_port = htons(port);
|
||||
|
||||
bcopy((char *)ent->h_addr, (char *)&serv.sin_addr.s_addr, ent->h_length);
|
||||
|
||||
int res = connect(sock, (struct sockaddr*)&serv, sizeof(serv));
|
||||
if(res < 0)
|
||||
{
|
||||
printf("error connect %s id %s\n", argv[1], argv[2]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char buffer[1024];
|
||||
sprintf(buffer, "{\"id\":1,\"method\":\"mining.update_block\",\"params\":[\"tu8tu5\",%d,\"%s\"]}\n", coinid, blockhash);
|
||||
|
||||
send(sock, buffer, strlen(buffer), 0);
|
||||
close(sock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
30
rc.local
Normal file
30
rc.local
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# rc.local
|
||||
#
|
||||
# This script is executed at the end of each multiuser runlevel.
|
||||
# Make sure that the script will "exit 0" on success or any other
|
||||
# value on error.
|
||||
#
|
||||
# In order to enable or disable this script just change the execution
|
||||
# bits.
|
||||
#
|
||||
# By default this script does nothing.
|
||||
|
||||
screen -dmS main /var/web/main.sh
|
||||
screen -dmS loop2 /var/web/loop2.sh
|
||||
screen -dmS blocks /var/web/blocks.sh
|
||||
|
||||
screen -dmS x11 /var/stratum/run.sh x11
|
||||
screen -dmS x13 /var/stratum/run.sh x13
|
||||
screen -dmS x15 /var/stratum/run.sh x15
|
||||
screen -dmS sha /var/stratum/run.sh sha
|
||||
screen -dmS scrypt1 /var/stratum/run.sh scrypt
|
||||
screen -dmS scrypt2 /var/stratum/run.sh scryptn
|
||||
screen -dmS neo /var/stratum/run.sh neo
|
||||
screen -dmS quark /var/stratum/run.sh quark
|
||||
screen -dmS qubit /var/stratum/run.sh qubit
|
||||
screen -dmS lyra2 /var/stratum/run.sh lyra2
|
||||
|
||||
exit 0
|
||||
|
25
web/run.php
Executable file
25
web/run.php
Executable file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
if(php_sapi_name() != "cli") return;
|
||||
|
||||
require_once('serverconfig.php');
|
||||
|
||||
require_once('framework-1.0.8/yii.php');
|
||||
require_once('yaamp/include.php');
|
||||
|
||||
$app = Yii::createWebApplication('yaamp/config.php');
|
||||
|
||||
try
|
||||
{
|
||||
$app->runController($argv[1]);
|
||||
}
|
||||
|
||||
catch(CException $e)
|
||||
{
|
||||
debuglog($e, 5);
|
||||
|
||||
// $message = $e->getMessage();
|
||||
// send_email_alert('backend', "backend error", "$message");
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Reference in a new issue