Browse Source

Merge pull request #102 from shesek/fix-relative-paths

Fix mining pool config path
fix-133-memory-crash
Dan Janosik 6 years ago
committed by GitHub
parent
commit
48b330b75c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app.js
  2. 4
      bin/refresh-mining-pool-configs.js

2
app.js

@ -216,7 +216,7 @@ function logBlockStats() {
function loadMiningPoolConfigs() { function loadMiningPoolConfigs() {
global.miningPoolsConfigs = []; global.miningPoolsConfigs = [];
var miningPoolsConfigDir = path.join(process.cwd(), "public", "txt", "mining-pools-configs", global.coinConfig.ticker); var miningPoolsConfigDir = path.join(__dirname, "public", "txt", "mining-pools-configs", global.coinConfig.ticker);
fs.readdir(miningPoolsConfigDir, function(err, files) { fs.readdir(miningPoolsConfigDir, function(err, files) {
if (err) { if (err) {

4
bin/refresh-mining-pool-configs.js

@ -13,7 +13,7 @@ async function refreshMiningPoolsForCoin(coinName) {
console.log(`Refreshing mining pools for ${coinName}...`); console.log(`Refreshing mining pools for ${coinName}...`);
if (coins[coinName].miningPoolsConfigUrls) { if (coins[coinName].miningPoolsConfigUrls) {
var miningPoolsConfigDir = path.join(process.cwd(), "public", "txt", "mining-pools-configs", coinName); var miningPoolsConfigDir = path.join(__dirname, "..", "public", "txt", "mining-pools-configs", coinName);
fs.readdir(miningPoolsConfigDir, function(err, files) { fs.readdir(miningPoolsConfigDir, function(err, files) {
if (err) { if (err) {
reject(`Unable to delete existing files from '${miningPoolsConfigDir}'`); reject(`Unable to delete existing files from '${miningPoolsConfigDir}'`);
@ -59,7 +59,7 @@ async function refreshMiningPoolConfig(coinName, index, url) {
if (!error && response && response.statusCode && response.statusCode == 200) { if (!error && response && response.statusCode && response.statusCode == 200) {
var responseBody = JSON.parse(body); var responseBody = JSON.parse(body);
var filename = path.join(process.cwd(), "public", "txt", "mining-pools-configs", coinName, index + ".json"); var filename = path.join(__dirname, "..", "public", "txt", "mining-pools-configs", coinName, index + ".json");
fs.writeFileSync(filename, body, function(err) { fs.writeFileSync(filename, body, function(err) {
console.log(`Error writing file '${filename}': ${err}`); console.log(`Error writing file '${filename}': ${err}`);

Loading…
Cancel
Save