From 42522a64eade2402209f9b66ef2a2421bc27eb19 Mon Sep 17 00:00:00 2001 From: BenDroid Date: Wed, 25 Oct 2017 22:48:59 +0200 Subject: [PATCH] Fixed backgrounding for XMRigCCServer on Windows Cleanup of default config files Extendend Readme.md --- README.md | 57 ++++++++++++++++--------------- howto_and_notes.txt | 75 ----------------------------------------- src/cc/CCServer.cpp | 47 +++++++++++++++++++++++++- src/cc/CCServer.h | 2 +- src/config.json | 2 +- src/default_config.json | 8 ++--- src/donate.h | 7 ++++ src/version.h | 12 ++++--- src/xmrigCC.cpp | 1 - 9 files changed, 96 insertions(+), 115 deletions(-) diff --git a/README.md b/README.md index c668656e..20ef60a5 100644 --- a/README.md +++ b/README.md @@ -16,39 +16,30 @@ The modified version can also handle commands like "update config", "start/stop XMRig is high performance Monero (XMR) / Aeon CPU miner, with the official full Windows support. Originally based on cpuminer-multi with heavy optimizations/rewrites and removing a lot of legacy code, since version 1.0.0 complete rewritten from scratch on C++. -* This is the CPU-mining version, there is also a [NVIDIA GPU version](https://github.com/xmrig/xmrig-nvidia). -* [Roadmap](https://github.com/xmrig/xmrig/issues/106) for next releases. - - - #### Table of contents -* [Features](#additional-features-of-xmrigcc) +* [Features](#features-of-xmrigcc) * [Download](#download) * [Usage](#usage) * [Algorithm variations](#algorithm-variations) -* [Build](https://raw.githubusercontent.com/Bendr0id/xmrigCC/master/howto_and_notes.txt) +* [Build on Debian/Ubuntu](https://github.com/Bendr0id/xmrigCC/wiki/Build-Debian%5CUbuntu) * [Common Issues](#common-issues) * [Other information](#other-information) * [Donations](#donations) * [Contacts](#contacts) +* [Wiki](https://github.com/Bendr0id/xmrigCC/wiki/) -## Additional features of xmrigCC +## Features of xmrigCC * Command and control server * CC Dashboard with: * statistics of all connected miners * remote control miners (start/stop/restart/shutdown) * remote configuration changes of miners * Daemon around the miner to restart and apply config changes -* AND all features of the latest xmrig - -## Features of xmrig * High performance. * Official Windows support. * Small Windows executable, without dependencies. -* x86/x64 support. * Support for backup (failover) mining server. * keepalived support. -* Command line options compatible with cpuminer. * CryptoNight-Lite support for AEON. * Smart automatic [CPU configuration](https://github.com/xmrig/xmrig/wiki/Threads). * Nicehash support @@ -65,7 +56,7 @@ Originally based on cpuminer-multi with heavy optimizations/rewrites and removin xmrigCCServer --cc-port=3344 --cc-user=admin --cc-pass=pass --cc-access-token=SECRET_TOKEN_TO_ACCESS_CC_SERVER ``` -### Options xmrigDaemon +### Options xmrigCCServer ``` --cc-user=USERNAME CC Server admin user --cc-pass=PASSWORD CC Server admin pass @@ -83,17 +74,14 @@ xmrigCCServer --cc-port=3344 --cc-user=admin --cc-pass=pass --cc-access-token=SE ``` +Also you can use configuration via config file, default **[config_cc.json](https://github.com/Bendr0id/xmrigCC/wiki/Config-XMRigCCServer)**. You can load multiple config files and combine it with command line options. + + ### Basic example xmrigDaemon ``` xmrigDaemon -o pool.minemonero.pro:5555 -u YOUR_WALLET -p x -k --cc-url=IP_OF_CC_SERVER:PORT --cc-access-token=SECRET_TOKEN_TO_ACCESS_CC_SERVER --cc-worker-id=OPTIONAL_WORKER_NAME ``` -### Failover xmrigDaemon -``` -xmrigDaemon -o pool.minemonero.pro:5555 -u YOUR_WALLET1 -p x -k -o pool.supportxmr.com:5555 -u YOUR_WALLET2 -p x -k --cc-url=IP_OF_CC_SERVER:PORT --cc-access-token=SECRET_TOKEN_TO_ACCESS_CC_SERVER --cc-worker-id=OPTIONAL_WORKER_NAME -``` -For failover you can add multiple pools, maximum count not limited. - ### Options xmrigDaemon ``` -a, --algo=ALGO cryptonight (default) or cryptonight-lite @@ -131,7 +119,7 @@ For failover you can add multiple pools, maximum count not limited. ``` -Also you can use configuration via config file, default **config.json**. You can load multiple config files and combine it with command line options. +Also you can use configuration via config file, default **[config.json](https://github.com/Bendr0id/xmrigCC/wiki/Config-XMRigMiner)**. You can load multiple config files and combine it with command line options. ## Algorithm variations Since version 0.8.0. @@ -141,10 +129,25 @@ Since version 0.8.0. * `--av=4` Lower power mode (double hash) of `3`. ## Common Issues -### HUGE PAGES unavailable +### Windows only: DLL error on starting +* Make sure that you installed latest Visual C++ Redistributable für Visual Studio 2015. Can be downloaded here: [microsoft.com](https://www.microsoft.com/de-de/download/details.aspx?id=48145) + +### Linux only: Background mode +* The `--background` option will only work properly for the XMRigServer. But there is a simple workaround for the XMRigDaemon process. Just append an `&` to the command and it will run smoothly in the background. + + `./xmrigDaemon --config=my_config_cc.json &` + + +### HUGE PAGES unavailable (Windows) * Run XMRig as Administrator. * Since version 0.8.0 XMRig automatically enable SeLockMemoryPrivilege for current user, but reboot or sign out still required. [Manual instruction](https://msdn.microsoft.com/en-gb/library/ms190730.aspx). +### HUGE PAGES unavailable (Linux) +* Before starting XMRigDaemon set huge pages + + `sudo sudo sysctl -w vm.nr_hugepages=256` + + ## Other information * No HTTP support, only stratum protocol support. * No TLS support. @@ -165,16 +168,16 @@ Please note performance is highly dependent on system load. The numbers above ar ## Donations * Default donation 5% (5 minutes in 100 minutes) can be reduced to 1% via command line option `--donate-level`. -* The donations will be automatically splitted (50/50) on my pool between xmrig and me. +* The donations will be automatically splitted (50/50) on my pool to xmrig's and my wallet. ##### BenDroid (xmrigCC): -XMR: `46FkYo7x6LqYjLQo4Jd84UTGBybW7tsWqJaQVLPhbUSK19ajSTMY9T2Sa2LH6CfWhSingjvQARtfeM4Feekpp2yFR1wsFNT` +XMR: `46FkYo7x6LqYjLQo4Jd84UTGBybW7tsWqJaQVLPhbUSK19ajSTMY9T2Sa2LH6CfWhSingjvQARtfeM4Feekpp2yFR1wsFNT` AEON: `Wmtm4S2cQ8uEBBAVjvbiaVAPv2d6gA1mAUmBmjna4VF7VixLxLRUYag5cvsym3WnuzdJ9zvhQ3Xwa8gWxPDPRfcQ3AUkYra3W` -BTC: `128qLZCaGdoWhBTfaS7rytpbvG4mNTyAQm` +BTC: `128qLZCaGdoWhBTfaS7rytpbvG4mNTyAQm` ##### xmrig: -XMR: `48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD` -BTC: `1P7ujsXeX7GxQwHNnJsRMgAdNkFZmNVqJT` +XMR: `48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD` +BTC: `1P7ujsXeX7GxQwHNnJsRMgAdNkFZmNVqJT` ## Contacts xmrigCC * ben [at] graef.in diff --git a/howto_and_notes.txt b/howto_and_notes.txt index 3ef1d8ef..251e2287 100644 --- a/howto_and_notes.txt +++ b/howto_and_notes.txt @@ -1,78 +1,3 @@ -installation: - -sudo apt-get install git build-essential cmake libuv1-dev libmicrohttpd-dev libcurl4-gnutls-dev - -(or any other libcurl) - -git clone https://github.com/Bendr0id/xmrigCC.git -cd xmrigCC -mkdir build -cd build -cmake .. -make - - -config cc server: - - sample is in src folder (config_cc.json): - -{ - "background": false, // true to run the cc-server in the background (no console) - "colors": true, // false to disable colored output - "log-file": null, // log all output to a file - "syslog": false, // use system log for output messages - "cc-server": { - "port": 3344, // port the CC Server will listens on - "access-token": null, // access token for CC Clients (should be set!!!) - "user": "admin", // admin user for access CC Dashboard - "pass": "pass", // admin pass for access CC Dashboard - "client-config-folder" : null, // folder which contains the client-config files (null=current) - "custom-dashboard" : "index.html" // dashboard html file - } -} - - -config cc client (miner): - - sample is in src folder (config.json): - -{ - "algo": "cryptonight-light", - "av": 0, - "background": false, - "colors": true, - "cpu-affinity": null, - "cpu-priority": null, - "donate-level": 0, - "log-file": null, - "max-cpu-usage": 75, - "print-time": 60, - "retries": 5, - "retry-pause": 5, - "safe": false, - "syslog": false, - "threads": null, - "pools": [ - { - "url": "pool.aeonmining.pro:3333", // your pool here - "user": "Wmtm4S2cQ8uEBBAVjvbiaVAPv2d6gA1mAUmBmjna4VF7VixLxLRUYag5cvsym3WnuzdJ9zvhQ3Xwa8gWxPDPRfcQ3AUkYra3W", // your wallet here - "pass": "donate", - "keepalive": true, - "nicehash": false - } - ], - "api": { - "port": 3339, // port for the miner API https://github.com/xmrig/xmrig/wiki/API - "access-token": null, // access token for API - "worker-id": null // custom worker-id for API - }, - "cc-client": { - "url": "localhost:3344", // url of the CC Server (ip:port) - "access-token": null, // access token for CC Server (has to be the same in config_cc.json) - "worker-id": null // custom worker-id for CC Server (otherwise hostname is used) - } -} - config to deploy / notes: diff --git a/src/cc/CCServer.cpp b/src/cc/CCServer.cpp index e4e5ceea..2eb89346 100644 --- a/src/cc/CCServer.cpp +++ b/src/cc/CCServer.cpp @@ -34,6 +34,13 @@ #include "Options.h" #include "Summary.h" +#if _WIN32 + #include + #include +#else +# include "unistd.h" +#endif + #ifdef HAVE_SYSLOG_H # include "log/SysLog.h" #endif @@ -90,6 +97,10 @@ int CCServer::start() uv_signal_start(&m_signal, CCServer::onSignal, SIGTERM); uv_signal_start(&m_signal, CCServer::onSignal, SIGINT); + if (m_options->background()) { + moveToBackground(); + } + Summary::print(); Service::start(); @@ -150,4 +161,38 @@ void CCServer::onSignal(uv_signal_t* handle, int signum) uv_signal_stop(handle); m_self->stop(); -} \ No newline at end of file +} + +void CCServer::moveToBackground() +{ +#ifdef WIN32 + HWND hcon = GetConsoleWindow(); + if (hcon) { + ShowWindow(hcon, SW_HIDE); + } else { + HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); + CloseHandle(h); + FreeConsole(); + } +#else + int i = fork(); + if (i < 0) { + exit(1); + } + + if (i > 0) { + exit(0); + } + + i = setsid(); + + if (i < 0) { + LOG_ERR("setsid() failed (errno = %d)", errno); + } + + i = chdir("/"); + if (i < 0) { + LOG_ERR("chdir() failed (errno = %d)", errno); + } +#endif +} diff --git a/src/cc/CCServer.h b/src/cc/CCServer.h index d53b10b0..fb4a3daa 100644 --- a/src/cc/CCServer.h +++ b/src/cc/CCServer.h @@ -49,6 +49,7 @@ protected: private: void stop(); + void moveToBackground(); static void onSignal(uv_signal_t* handle, int signum); @@ -58,7 +59,6 @@ private: Httpd* m_httpd; Options* m_options; uv_signal_t m_signal; - }; diff --git a/src/config.json b/src/config.json index e7e55e21..786b7a23 100644 --- a/src/config.json +++ b/src/config.json @@ -16,7 +16,7 @@ "threads": null, // number of miner threads "pools": [ { - "url": "pool.minemonero.pro:5555", // URL of mining server + "url": "", // URL of mining server "user": "", // username for mining server "pass": "x", // password for mining server "keepalive": true, // send keepalived for prevent timeout (need pool support) diff --git a/src/default_config.json b/src/default_config.json index e7e55e21..f07577a0 100644 --- a/src/default_config.json +++ b/src/default_config.json @@ -2,12 +2,12 @@ "algo": "cryptonight", // cryptonight (default) or cryptonight-lite "av": 0, // algorithm variation, 0 auto select "background": false, // true to run the miner in the background - "colors": true, // false to disable colored output + "colors": true, // false to disable colored output "cpu-affinity": null, // set process affinity to CPU core(s), mask "0x3" for cores 0 and 1 "cpu-priority": null, // set process priority (0 idle, 2 normal to 5 highest) "donate-level": 5, // donate level, mininum 1% "log-file": null, // log all output to a file, example: "c:/some/path/xmrig.log" - "max-cpu-usage": 75, // maximum CPU usage for automatic mode, usually limiting factor is CPU cache not this option. + "max-cpu-usage": 75, // maximum CPU usage for automatic mode, usually limiting factor is CPU cache not this option. "print-time": 60, // print hashrate report every N seconds "retries": 5, // number of times to retry before switch to backup server "retry-pause": 5, // time to pause between retries @@ -16,7 +16,7 @@ "threads": null, // number of miner threads "pools": [ { - "url": "pool.minemonero.pro:5555", // URL of mining server + "url": "", // URL of mining server "user": "", // username for mining server "pass": "x", // password for mining server "keepalive": true, // send keepalived for prevent timeout (need pool support) @@ -33,4 +33,4 @@ "access-token": null, // access token for CC Server (has to be the same in config_cc.json) "worker-id": null // custom worker-id for CC Server (otherwise hostname is used) } -} +} \ No newline at end of file diff --git a/src/donate.h b/src/donate.h index 3a000948..485f8f71 100644 --- a/src/donate.h +++ b/src/donate.h @@ -5,6 +5,7 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2016-2017 XMRig + * Copyright 2017- BenDr0id * * * This program is free software: you can redistribute it and/or modify @@ -34,8 +35,14 @@ * Switching is instant, and only happens after a successful connection, so you never loose any hashes. * * If you plan on changing this setting to 0 please consider making a one off donation to my wallet: + * XMR: 46FkYo7x6LqYjLQo4Jd84UTGBybW7tsWqJaQVLPhbUSK19ajSTMY9T2Sa2LH6CfWhSingjvQARtfeM4Feekpp2yFR1wsFNT + * BTC: 128qLZCaGdoWhBTfaS7rytpbvG4mNTyAQm + * AEON: Wmtm4S2cQ8uEBBAVjvbiaVAPv2d6gA1mAUmBmjna4VF7VixLxLRUYag5cvsym3WnuzdJ9zvhQ3Xwa8gWxPDPRfcQ3AUkYra3W + * + * XMRig's wallet: * XMR: 48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD * BTC: 1P7ujsXeX7GxQwHNnJsRMgAdNkFZmNVqJT + * */ constexpr const int kDonateLevel = 5; diff --git a/src/version.h b/src/version.h index 59d30e83..ab8e199d 100644 --- a/src/version.h +++ b/src/version.h @@ -5,6 +5,7 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2016-2017 XMRig + * Copyright 2017- BenDr0id * * * This program is free software: you can redistribute it and/or modify @@ -28,16 +29,17 @@ #define APP_ID "xmrigCC" #define APP_NAME "XMRigCC" #define APP_DESC "XMRigCC Command'n'Control Server" -#define APP_VERSION "1.0.0" +#define APP_VERSION "1.0.4" +#define APP_COPYRIGHT "Copyright (C) 2017- BenDr0id" # else #define APP_ID "xmrigCC" #define APP_NAME "XMRigCC" #define APP_DESC "XMRigCC CPU miner" -#define APP_VERSION "2.4.1" +#define APP_VERSION "2.4.2" +#define APP_COPYRIGHT "Copyright (C) 2017- BenDr0id" #endif -#define APP_DOMAIN "xmrig.com" -#define APP_SITE "www.xmrig.com" -#define APP_COPYRIGHT "Copyright (C) 2016-2017 xmrig.com" +#define APP_DOMAIN "" +#define APP_SITE "https://github.com/Bendr0id/xmrigCC" #define APP_KIND "cpu" #define APP_VER_MAJOR 2 diff --git a/src/xmrigCC.cpp b/src/xmrigCC.cpp index 50529d99..c8bcddeb 100644 --- a/src/xmrigCC.cpp +++ b/src/xmrigCC.cpp @@ -27,6 +27,5 @@ int main(int argc, char** argv) { CCServer ccServer(argc, argv); - return ccServer.start(); }