diff --git a/README.md b/README.md old mode 100644 new mode 100755 index a6b5fc5..77fc76f --- a/README.md +++ b/README.md @@ -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/ + + diff --git a/blocknotify/blocknotify.cpp b/blocknotify/blocknotify.cpp new file mode 100755 index 0000000..cb63959 --- /dev/null +++ b/blocknotify/blocknotify.cpp @@ -0,0 +1,90 @@ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// 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; +} + + + + + + + + + + diff --git a/rc.local b/rc.local new file mode 100644 index 0000000..217d2b5 --- /dev/null +++ b/rc.local @@ -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 + diff --git a/web/run.php b/web/run.php new file mode 100755 index 0000000..6db4355 --- /dev/null +++ b/web/run.php @@ -0,0 +1,25 @@ +runController($argv[1]); +} + +catch(CException $e) +{ + debuglog($e, 5); + +// $message = $e->getMessage(); +// send_email_alert('backend', "backend error", "$message"); +} + +