Browse Source

Add quiet mode option which suppresses throbber

master
Con Kolivas 8 years ago
parent
commit
14c8a3a125
  1. 7
      src/ckpool.c
  2. 3
      src/ckpool.h
  3. 11
      src/stratifier.c

7
src/ckpool.c

@ -1542,6 +1542,7 @@ static struct option long_options[] = {
{"node", no_argument, 0, 'N'},
{"passthrough", no_argument, 0, 'P'},
{"proxy", no_argument, 0, 'p'},
{"quiet", no_argument, 0, 'q'},
{"redirector", no_argument, 0, 'R'},
{"ckdb-sockdir",required_argument, 0, 'S'},
{"sockdir", required_argument, 0, 's'},
@ -1563,6 +1564,7 @@ static struct option long_options[] = {
{"node", no_argument, 0, 'N'},
{"passthrough", no_argument, 0, 'P'},
{"proxy", no_argument, 0, 'p'},
{"quiet", no_argument, 0, 'q'},
{"redirector", no_argument, 0, 'R'},
{"sockdir", required_argument, 0, 's'},
{"trusted", no_argument, 0, 't'},
@ -1610,7 +1612,7 @@ int main(int argc, char **argv)
ckp.initial_args[ckp.args] = strdup(argv[ckp.args]);
ckp.initial_args[ckp.args] = NULL;
while ((c = getopt_long(argc, argv, "Ac:Dd:g:HhkLl:Nn:PpRS:s:tu", long_options, &i)) != -1) {
while ((c = getopt_long(argc, argv, "Ac:Dd:g:HhkLl:Nn:PpqRS:s:tu", long_options, &i)) != -1) {
switch (c) {
case 'A':
ckp.standalone = true;
@ -1679,6 +1681,9 @@ int main(int argc, char **argv)
quit(1, "Cannot set another proxy type or redirector and proxy mode");
ckp.proxy = true;
break;
case 'q':
ckp.quiet = true;
break;
case 'R':
if (ckp.proxy || ckp.passthrough || ckp.userproxy || ckp.node)
quit(1, "Cannot set a proxy type or passthrough and redirector modes");

3
src/ckpool.h

@ -209,6 +209,9 @@ struct ckpool_instance {
/* Should we daemonise the ckpool process */
bool daemon;
/* Should we disable the throbber */
bool quiet;
/* Have we given warnings about the inability to raise buf sizes */
bool wmem_warn;
bool rmem_warn;

11
src/stratifier.c

@ -777,22 +777,22 @@ out:
static void _ckdbq_add(ckpool_t *ckp, const int idtype, json_t *val, const char *file,
const char *func, const int line)
{
static time_t time_counter;
sdata_t *sdata = ckp->sdata;
static time_t time_counter;
static int counter = 0;
char *json_msg;
time_t now_t;
char ch;
if (unlikely(!val)) {
LOGWARNING("Invalid json sent to ckdbq_add from %s %s:%d", file, func, line);
return;
}
now_t = time(NULL);
if (!ckp->quiet) {
time_t now_t = time(NULL);
if (now_t != time_counter) {
pool_stats_t *stats = &sdata->stats;
char hashrate[16];
char hashrate[16], ch;
/* Rate limit to 1 update per second */
time_counter = now_t;
@ -802,6 +802,7 @@ static void _ckdbq_add(ckpool_t *ckp, const int idtype, json_t *val, const char
ch, hashrate, stats->sps1, stats->users, stats->workers);
fflush(stdout);
}
}
if (CKP_STANDALONE(ckp))
return json_decref(val);

Loading…
Cancel
Save