Add config property to enable/disable config upload on startup

This commit is contained in:
BenDr0id 2018-08-02 13:57:07 +02:00
parent ed80e8a436
commit 4ae65643ba
7 changed files with 25 additions and 10 deletions

View file

@ -97,7 +97,8 @@ Options:\n"
--cc-access-token=T access token for CC Server\n\ --cc-access-token=T access token for CC Server\n\
--cc-worker-id=ID custom worker-id for CC Server\n\ --cc-worker-id=ID custom worker-id for CC Server\n\
--cc-update-interval-s=N status update interval in seconds (default: 10 min: 1)\n\ --cc-update-interval-s=N status update interval in seconds (default: 10 min: 1)\n\
--cc-use-remote-logging enable remote logging on CC Server\n" --cc-use-remote-logging enable remote logging on CC Server\n\
--cc-upload-config-on-startup upload current miner config to CC Server on startup\n"
# endif # endif
# endif # endif
@ -184,6 +185,7 @@ static struct option const options[] = {
{ "cc-use-tls", 0, nullptr, 4016 }, { "cc-use-tls", 0, nullptr, 4016 },
{ "cc-use-remote-logging", 0, nullptr, 4017 }, { "cc-use-remote-logging", 0, nullptr, 4017 },
{ "cc-client-log-lines-history", 1, nullptr, 4018 }, { "cc-client-log-lines-history", 1, nullptr, 4018 },
{ "cc-upload-config-on-startup", 0, nullptr, 4019 },
{ "daemonized", 0, nullptr, 4011 }, { "daemonized", 0, nullptr, 4011 },
{ "doublehash-thread-mask", 1, nullptr, 4013 }, { "doublehash-thread-mask", 1, nullptr, 4013 },
{ "multihash-thread-mask", 1, nullptr, 4013 }, { "multihash-thread-mask", 1, nullptr, 4013 },
@ -246,6 +248,7 @@ static struct option const cc_client_options[] = {
{ "update-interval-s", 1, nullptr, 4012 }, { "update-interval-s", 1, nullptr, 4012 },
{ "use-tls", 0, nullptr, 4016 }, { "use-tls", 0, nullptr, 4016 },
{ "use-remote-logging", 0, nullptr, 4017 }, { "use-remote-logging", 0, nullptr, 4017 },
{ "upload-config-on-startup", 0, nullptr, 4019 },
{ nullptr, 0, nullptr, 0 } { nullptr, 0, nullptr, 0 }
}; };
@ -320,6 +323,7 @@ Options::Options(int argc, char **argv) :
m_daemonized(false), m_daemonized(false),
m_ccUseTls(false), m_ccUseTls(false),
m_ccUseRemoteLogging(true), m_ccUseRemoteLogging(true),
m_ccUploadConfigOnStartup(true),
m_configFile(Platform::defaultConfigName()), m_configFile(Platform::defaultConfigName()),
m_apiToken(nullptr), m_apiToken(nullptr),
m_apiWorkerId(nullptr), m_apiWorkerId(nullptr),
@ -587,6 +591,9 @@ bool Options::parseArg(int key, const char *arg)
case 4017: /* --cc-use-remote-logging */ case 4017: /* --cc-use-remote-logging */
return parseBoolean(key, true); return parseBoolean(key, true);
case 4019: /* --cc-upload-config-on-startup */
return parseBoolean(key, true);
case 't': /* --threads */ case 't': /* --threads */
if (strncmp(arg, "all", 3) == 0) { if (strncmp(arg, "all", 3) == 0) {
m_threads = Cpu::threads(); m_threads = Cpu::threads();
@ -823,6 +830,10 @@ bool Options::parseBoolean(int key, bool enable)
m_ccUseRemoteLogging = enable; m_ccUseRemoteLogging = enable;
break; break;
case 4019: /* --cc-upload-config-on-startup */
m_ccUploadConfigOnStartup = enable;
break;
default: default:
break; break;
} }

View file

@ -73,6 +73,7 @@ public:
inline bool daemonized() const { return m_daemonized; } inline bool daemonized() const { return m_daemonized; }
inline bool ccUseTls() const { return m_ccUseTls; } inline bool ccUseTls() const { return m_ccUseTls; }
inline bool ccUseRemoteLogging() const { return m_ccUseRemoteLogging; } inline bool ccUseRemoteLogging() const { return m_ccUseRemoteLogging; }
inline bool ccUploadConfigOnStartup() const { return m_ccUploadConfigOnStartup; }
inline const char *configFile() const { return m_configFile; } inline const char *configFile() const { return m_configFile; }
inline const char *apiToken() const { return m_apiToken; } inline const char *apiToken() const { return m_apiToken; }
inline const char *apiWorkerId() const { return m_apiWorkerId; } inline const char *apiWorkerId() const { return m_apiWorkerId; }
@ -147,6 +148,7 @@ private:
bool m_daemonized; bool m_daemonized;
bool m_ccUseTls; bool m_ccUseTls;
bool m_ccUseRemoteLogging; bool m_ccUseRemoteLogging;
bool m_ccUploadConfigOnStartup;
const char* m_configFile; const char* m_configFile;
char *m_apiToken; char *m_apiToken;
char *m_apiWorkerId; char *m_apiWorkerId;

View file

@ -320,7 +320,9 @@ void CCClient::onThreadStarted(void* handle)
static_cast<uint64_t>(m_self->m_options->ccUpdateInterval() * 1000), static_cast<uint64_t>(m_self->m_options->ccUpdateInterval() * 1000),
static_cast<uint64_t>(m_self->m_options->ccUpdateInterval() * 1000)); static_cast<uint64_t>(m_self->m_options->ccUpdateInterval() * 1000));
if (m_self->m_options->ccUploadConfigOnStartup()) {
m_self->publishConfig(); m_self->publishConfig();
}
uv_run(&m_self->m_client_loop, UV_RUN_DEFAULT); uv_run(&m_self->m_client_loop, UV_RUN_DEFAULT);
} }

View file

@ -288,8 +288,6 @@ unsigned Service::getClientLog(const std::string& clientId, std::string& resp)
data << m_row.c_str() << std::endl; data << m_row.c_str() << std::endl;
} }
LOG_INFO("LOG: %s", data.str().c_str());
respDocument.AddMember("client_log", rapidjson::StringRef(data.str().c_str()), allocator); respDocument.AddMember("client_log", rapidjson::StringRef(data.str().c_str()), allocator);
rapidjson::StringBuffer buffer(0, 4096); rapidjson::StringBuffer buffer(0, 4096);

View file

@ -35,6 +35,7 @@
"worker-id": null, // custom worker-id for CC Server (otherwise hostname is used) "worker-id": null, // custom worker-id for CC Server (otherwise hostname is used)
"update-interval-s": 10, // status update interval in seconds (default: 10 min: 1) "update-interval-s": 10, // status update interval in seconds (default: 10 min: 1)
"use-remote-logging" : true, // enable remote logging on CC Server "use-remote-logging" : true, // enable remote logging on CC Server
"remote-logging-max-rows" : 20 // maximum last n-log rows to send CC Server "remote-logging-max-rows" : 20, // maximum last n-log rows to send CC Server
"upload-config-on-startup" : true // upload current miner config to CC Server on startup
} }
} }

View file

@ -35,6 +35,7 @@
"worker-id": null, // custom worker-id for CC Server (otherwise hostname is used) "worker-id": null, // custom worker-id for CC Server (otherwise hostname is used)
"update-interval-s": 10, // status update interval in seconds (default: 10 min: 1) "update-interval-s": 10, // status update interval in seconds (default: 10 min: 1)
"use-remote-logging" : true, // enable remote logging on CC Server "use-remote-logging" : true, // enable remote logging on CC Server
"remote-logging-max-rows" : 20 // maximum last n-log rows to send CC Server "remote-logging-max-rows" : 20, // maximum last n-log rows to send CC Server
"upload-config-on-startup" : true // upload current miner config to CC Server on startup
} }
} }

View file

@ -36,14 +36,14 @@
#define APP_DESC "XMRigCC CPU miner" #define APP_DESC "XMRigCC CPU miner"
#define APP_COPYRIGHT "Copyright (C) 2017- BenDr0id" #define APP_COPYRIGHT "Copyright (C) 2017- BenDr0id"
#endif #endif
#define APP_VERSION "1.6.5 (based on XMRig)" #define APP_VERSION "1.6.6_beta1 (based on XMRig)"
#define APP_DOMAIN "" #define APP_DOMAIN ""
#define APP_SITE "https://github.com/Bendr0id/xmrigCC" #define APP_SITE "https://github.com/Bendr0id/xmrigCC"
#define APP_KIND "cpu" #define APP_KIND "cpu"
#define APP_VER_MAJOR 1 #define APP_VER_MAJOR 1
#define APP_VER_MINOR 6 #define APP_VER_MINOR 6
#define APP_VER_BUILD 5 #define APP_VER_BUILD 6
#define APP_VER_REV 0 #define APP_VER_REV 0
#ifndef NDEBUG #ifndef NDEBUG