From 9d04e11bb63a742acc310e7be500ff092132e887 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 31 Aug 2014 09:55:40 +1000 Subject: [PATCH] Store pool and user logs in separate subdirectories --- src/ckpool.c | 12 ++++++++++++ src/stratifier.c | 10 +++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/ckpool.c b/src/ckpool.c index c88781ad..840057ed 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -1226,6 +1226,18 @@ int main(int argc, char **argv) if (ret && errno != EEXIST) quit(1, "Failed to make log directory %s", ckp.logdir); + /* Create the user logdir */ + sprintf(buf, "%s/users", ckp.logdir); + ret = mkdir(buf, 0750); + if (ret && errno != EEXIST) + quit(1, "Failed to make user log directory %s", buf); + + /* Create the pool logdir */ + sprintf(buf, "%s/pool", ckp.logdir); + ret = mkdir(buf, 0750); + if (ret && errno != EEXIST) + quit(1, "Failed to make pool log directory %s", buf); + /* Create the logfile */ sprintf(buf, "%s%s.log", ckp.logdir, ckp.name); ckp.logfp = fopen(buf, "ae"); diff --git a/src/stratifier.c b/src/stratifier.c index fe630572..26e0f3e7 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -2474,7 +2474,7 @@ static void *statsupdate(void *arg) ghs1440 = stats.dsps1440 * nonces / bias; suffix_string(ghs1440, suffix1440, 16, 0); - snprintf(fname, 511, "%s/pool.status", ckp->logdir); + snprintf(fname, 511, "%s/pool/pool.status", ckp->logdir); fp = fopen(fname, "we"); if (unlikely(!fp)) LOGERR("Failed to fopen %s", fname); @@ -2483,7 +2483,7 @@ static void *statsupdate(void *arg) "runtime", diff.tv_sec, "Users", stats.users, "Workers", stats.workers); - s = json_dumps(val, JSON_NO_UTF8); + s = json_dumps(val, JSON_NO_UTF8 | JSON_PRESERVE_ORDER); json_decref(val); LOGNOTICE("Pool:%s", s); fprintf(fp, "%s\n", s); @@ -2496,7 +2496,7 @@ static void *statsupdate(void *arg) "hashrate1hr", suffix60, "hashrate6hr", suffix360, "hashrate1d", suffix1440); - s = json_dumps(val, JSON_NO_UTF8); + s = json_dumps(val, JSON_NO_UTF8 | JSON_PRESERVE_ORDER); json_decref(val); LOGNOTICE("Pool:%s", s); fprintf(fp, "%s\n", s); @@ -2507,7 +2507,7 @@ static void *statsupdate(void *arg) "SPS5m", sps5, "SPS15m", sps15, "SPS1h", sps60); - s = json_dumps(val, JSON_NO_UTF8); + s = json_dumps(val, JSON_NO_UTF8 | JSON_PRESERVE_ORDER); json_decref(val); LOGNOTICE("Pool:%s", s); fprintf(fp, "%s\n", s); @@ -2558,7 +2558,7 @@ static void *statsupdate(void *arg) "hashrate1d", suffix1440, "workers", instance->workers); - snprintf(fname, 511, "%s/%s", ckp->logdir, instance->username); + snprintf(fname, 511, "%s/users/%s", ckp->logdir, instance->username); fp = fopen(fname, "we"); if (unlikely(!fp)) { LOGERR("Failed to fopen %s", fname);