Browse Source

Provide an option to run ckpool standalone without ckdb

master
Con Kolivas 11 years ago
parent
commit
dd056cd030
  1. 34
      src/ckpool.c
  2. 3
      src/ckpool.h

34
src/ckpool.c

@ -948,6 +948,7 @@ static void *watchdog(void *arg)
} }
static struct option long_options[] = { static struct option long_options[] = {
{"standalone", no_argument, 0, 'A'},
{"config", required_argument, 0, 'c'}, {"config", required_argument, 0, 'c'},
{"ckdb-name", required_argument, 0, 'd'}, {"ckdb-name", required_argument, 0, 'd'},
{"group", required_argument, 0, 'g'}, {"group", required_argument, 0, 'g'},
@ -975,8 +976,11 @@ int main(int argc, char **argv)
memset(&ckp, 0, sizeof(ckp)); memset(&ckp, 0, sizeof(ckp));
ckp.loglevel = LOG_NOTICE; ckp.loglevel = LOG_NOTICE;
while ((c = getopt_long(argc, argv, "c:d:g:hkl:n:pS:s:", long_options, &i)) != -1) { while ((c = getopt_long(argc, argv, "Ac:d:g:hkl:n:pS:s:", long_options, &i)) != -1) {
switch (c) { switch (c) {
case 'A':
ckp.standalone = true;
break;
case 'c': case 'c':
ckp.config = optarg; ckp.config = optarg;
break; break;
@ -1000,7 +1004,7 @@ int main(int argc, char **argv)
printf("-%c %s | --%s %s\n", jopt->val, printf("-%c %s | --%s %s\n", jopt->val,
upper, jopt->name, upper); upper, jopt->name, upper);
} else } else
printf("-%c | %s\n", jopt->val, jopt->name); printf("-%c | --%s\n", jopt->val, jopt->name);
} }
exit(0); exit(0);
case 'k': case 'k':
@ -1057,20 +1061,22 @@ int main(int argc, char **argv)
} }
trail_slash(&ckp.socket_dir); trail_slash(&ckp.socket_dir);
if (!ckp.ckdb_name) if (!ckp.standalone) {
ckp.ckdb_name = "ckdb"; if (!ckp.ckdb_name)
if (!ckp.ckdb_sockdir) { ckp.ckdb_name = "ckdb";
ckp.ckdb_sockdir = strdup("/opt/"); if (!ckp.ckdb_sockdir) {
realloc_strcat(&ckp.ckdb_sockdir, ckp.ckdb_name); ckp.ckdb_sockdir = strdup("/opt/");
} realloc_strcat(&ckp.ckdb_sockdir, ckp.ckdb_name);
trail_slash(&ckp.ckdb_sockdir); }
trail_slash(&ckp.ckdb_sockdir);
ret = mkdir(ckp.ckdb_sockdir, 0750); ret = mkdir(ckp.ckdb_sockdir, 0750);
if (ret && errno != EEXIST) if (ret && errno != EEXIST)
quit(1, "Failed to make directory %s", ckp.ckdb_sockdir); quit(1, "Failed to make directory %s", ckp.ckdb_sockdir);
ckp.ckdb_sockname = ckp.ckdb_sockdir; ckp.ckdb_sockname = ckp.ckdb_sockdir;
realloc_strcat(&ckp.ckdb_sockname, "listener"); realloc_strcat(&ckp.ckdb_sockname, "listener");
}
/* Ignore sigpipe */ /* Ignore sigpipe */
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);

3
src/ckpool.h

@ -98,6 +98,9 @@ struct ckpool_instance {
/* Are we running as a proxy */ /* Are we running as a proxy */
bool proxy; bool proxy;
/* Are we running without ckdb */
bool standalone;
/* Bitcoind data */ /* Bitcoind data */
int btcds; int btcds;
char **btcdurl; char **btcdurl;

Loading…
Cancel
Save