Added configuration for cclient update status interval

This commit is contained in:
BenDroid 2017-11-03 20:12:04 +01:00
parent 4e89560417
commit deaefe4d96
8 changed files with 37 additions and 18 deletions

View file

@ -1,3 +1,5 @@
# v1.0.7
- CCClient status update interval is now configurable
# v1.0.6
- Fixed launch in folder containing spaces (Win)
# v1.0.5

View file

@ -46,18 +46,16 @@ $(document).ready(function() {
targets: -1,
data: null,
defaultContent:
"<div class='btn-group btn-group-xs'>" +
"<button type='button' id='START' class='btn btn-success' data-toggle='tooltip' title='Start'><i class='fa fa-play'></i></button>" +
"<button type='button' id='STOP' class='btn btn-warning' data-toggle='tooltip' title='Stop'><i class='fa fa-pause'></i></button>" +
"<button type='button' id='RESTART' class='btn' data-toggle='tooltip' title='Restart'><i class='fa fa-repeat'></i></button>" +
"<button type='button' id='UPDATE_CONFIG' class='btn btn-info' data-toggle='tooltip' title='Update Config'><i class='fa fa-refresh'></i></button>" +
"<button type='button' id='EDIT' class='btn btn-primary' data-toggle='tooltip' title='Edit Client Config'><i class='fa fa-cog'></i></button>" +
"<button type='button' id='SHUTDOWN' class='btn btn-danger' data-toggle='tooltip' title='Stutdown Client'><i class='fa fa-power-off'></i></button>" +
"</div>",
"<td><button type='button' id='START' class='btn btn-xs btn-success' data-toggle='tooltip' title='Start'><i class='fa fa-play'></i></button></td>" +
"<td><button type='button' id='STOP' class='btn btn-xs btn-warning' data-toggle='tooltip' title='Stop'><i class='fa fa-pause'></i></button></td>" +
"<td><button type='button' id='RESTART' class='btn btn-xs' data-toggle='tooltip' title='Restart'><i class='fa fa-repeat'></i></button></td>" +
"<td><button type='button' id='UPDATE_CONFIG' class='btn btn-xs btn-info' data-toggle='tooltip' title='Update Config'><i class='fa fa-refresh'></i></button></td>" +
"<td><button type='button' id='EDIT' class='btn btn-xs btn-primary' data-toggle='tooltip' title='Edit Client Config'><i class='fa fa-cog'></i></button></td>" +
"<td><button type='button' id='SHUTDOWN' class='btn btn-xs btn-danger' data-toggle='tooltip' title='Stutdown Client'><i class='fa fa-power-off'></i></button></td>",
className: "center"
}
],
order: [ 11, 'desc' ],
order: [ 12, 'desc' ],
});
$('#clientStatusList tbody').on( 'click', 'button', function () {
@ -155,7 +153,7 @@ function round( data, type, row ) {
<th>Shares Good</th>
<th>Shares Total</th>
<th>Last Update</th>
<th>Action</th>
<th colspan="6" class="center">Action</th>
</tr>
</thead>
</table>

View file

@ -84,7 +84,8 @@ Options:\n"
"\
--cc-url=URL url of the 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 status update interval in seconds (default: 10 min: 1)\n"
# endif
# endif
@ -148,6 +149,7 @@ static struct option const options[] = {
{ "cc-url", 1, nullptr, 4003 },
{ "cc-access-token", 1, nullptr, 4004 },
{ "cc-worker-id", 1, nullptr, 4005 },
{ "cc-update-interval-s", 1, nullptr, 4012 },
{ "cc-port", 1, nullptr, 4006 },
{ "cc-user", 1, nullptr, 4007 },
{ "cc-pass", 1, nullptr, 4008 },
@ -200,9 +202,10 @@ static struct option const api_options[] = {
static struct option const cc_client_options[] = {
{ "url", 1, nullptr, 4003 },
{ "access-token", 1, nullptr, 4004 },
{ "worker-id", 1, nullptr, 4005 },
{ "url", 1, nullptr, 4003 },
{ "access-token", 1, nullptr, 4004 },
{ "worker-id", 1, nullptr, 4005 },
{ "update-interval-s", 1, nullptr, 4012 },
{ 0, 0, 0, 0 }
};
@ -274,6 +277,7 @@ Options::Options(int argc, char **argv) :
m_retries(5),
m_retryPause(5),
m_threads(0),
m_ccUpdateInterval(10),
m_ccPort(0),
m_affinity(-1L)
{
@ -473,6 +477,7 @@ bool Options::parseArg(int key, const char *arg)
free(m_ccCustomDashboard);
m_ccCustomDashboard = strdup(arg);
break;
case 4011: /* --daemonized */
m_daemonized = true;
break;
@ -488,6 +493,8 @@ bool Options::parseArg(int key, const char *arg)
return parseArg(key, strtol(arg, nullptr, 10));
case 4006: /* --cc-port */
return parseArg(key, strtol(arg, nullptr, 10));
case 4012: /* --cc-update-interval-c */
return parseArg(key, strtol(arg, nullptr, 10));
case 'B': /* --background */
case 'k': /* --keepalive */
@ -627,7 +634,14 @@ bool Options::parseArg(int key, uint64_t arg)
m_ccPort = (int) arg;
}
break;
case 4012: /* --cc-update-interval-s */
if (arg < 1) {
showUsage(1);
return false;
}
m_ccUpdateInterval = (int) arg;
break;
default:
break;
}

View file

@ -85,6 +85,7 @@ public:
inline int retries() const { return m_retries; }
inline int retryPause() const { return m_retryPause; }
inline int threads() const { return m_threads; }
inline int ccUpdateInterval() const { return m_ccUpdateInterval; }
inline int ccPort() const { return m_ccPort; }
inline int64_t affinity() const { return m_affinity; }
@ -148,6 +149,7 @@ private:
int m_retries;
int m_retryPause;
int m_threads;
int m_ccUpdateInterval;
int m_ccPort;
int64_t m_affinity;
std::vector<Url*> m_pools;

View file

@ -74,7 +74,9 @@ CCClient::CCClient(const Options *options)
}
uv_timer_init(uv_default_loop(), &m_timer);
uv_timer_start(&m_timer, CCClient::onReport, kTickInterval, kTickInterval);
uv_timer_start(&m_timer, CCClient::onReport,
static_cast<uint64_t>(m_options->ccUpdateInterval() * 1000),
static_cast<uint64_t>(m_options->ccUpdateInterval() * 1000));
}
CCClient::~CCClient()

View file

@ -54,7 +54,6 @@ private:
static void onReport(uv_timer_t *handle);
static int onResponse(char* data, size_t size, size_t nmemb, std::string* responseBuffer);
constexpr static int kTickInterval = 10 * 1000;
const Options *m_options;
static CCClient* m_self;

View file

@ -31,6 +31,7 @@
"cc-client": {
"url": "localhost:3344", // url of the CC Server (ip:port)
"access-token": "mySecret", // 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)
"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)
}
}

View file

@ -31,6 +31,7 @@
"cc-client": {
"url": "localhost:3344", // url of the CC Server (ip:port)
"access-token": "mySecret", // 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)
"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)
}
}