Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #245 from aleitner/master
Browse files Browse the repository at this point in the history
Remove bridgeUri from config
  • Loading branch information
braydonf committed Sep 6, 2017
2 parents ad48006 + 8d47e96 commit 96d46a9
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 31 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,19 @@ storjshare start --config path/to/config.json
* starting share with config at path/to/config.json
```

#### Updating storjshare and restoring sessions

If you want to upgrade storjshare you can save your current session and
reload it after updating

```
storjshare save
storjshare killall
npm install -g storjshare-daemon
storjshare daemon &
storjshare load
```

## License

Storj Share - Daemon + CLI for farming data on the Storj network.
Expand Down
7 changes: 6 additions & 1 deletion example/farmer.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
"maxOfferConcurrency": 3,
// If the seedList is empty, use this bridge to discover seeds
// Following a transfer, also send an exchange report to this bridge
"bridgeUri": "https://api.storj.io",
"bridges":[
{
"url": "https://api.storj.io",
"extendedKey": "xpub6AHweYHAxk1EhJSBctQD1nLWPog6Sy2eTpKQLExR1hfzTyyZQWvU4EYNXv1NJN7GpLYXnDLt4PzN874g6zSjAQdFCHZN7U7nbYKYVDUzD42"
}
],
// Known preferred seeds in form of a storj URI
// Example: "storj://[ip.or.hostname]:[port]/[nodeid]"
"seedList": [],
Expand Down
1 change: 0 additions & 1 deletion lib/config/farmer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const config = require('rc')('storjfarmer', {
'0f03020202'
],
maxOfferConcurrency: 3,
bridgeUri: 'https://api.storj.io',
seedList: [],
rpcAddress: '127.0.0.1',
rpcPort: 4000,
Expand Down
33 changes: 7 additions & 26 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const net = require('net');
const fs = require('fs');
const storj = require('storj-lib');
const {bitcore} = storj.deps;
const du = require('du');
const diskspace = require('fd-diskspace').diskSpace;
const du = require('du'); // Get amount used
const disk = require('diskusage'); // Get amount free
const assert = require('assert');
const bytes = require('bytes');

Expand Down Expand Up @@ -107,6 +107,9 @@ exports.validateAllocation = function(conf, callback) {

self.getFreeSpace(conf.storagePath, function(err, free) {
var allocatedSpace = bytes.parse(conf.storageAllocation);
if (err) {
callback(err);
}

self.getDirectorySize(conf.storagePath, function(err, usedSpaceBytes) {
if (err) {
Expand Down Expand Up @@ -176,34 +179,12 @@ exports.getFreeSpace = function(path, callback) {
return callback(null, 0);
}

diskspace(function(err, result) {
/* jshint maxcomplexity:10 */
disk.check(path, function(err, info) {
if (err) {
return callback(err);
}

let free = 0;

for (let disk in result.disks) {
let diskDrive = disk;

/* istanbul ignore if */
if (process.platform === 'win32') {
diskDrive += ':\\';
}

if (exports.existsSync(diskDrive)) {
if (fs.statSync(path).dev === fs.statSync(diskDrive).dev) {
// NB: The `df` command on gnu+linux returns KB by default
// NB: so we need to convert to bytes.
free = process.platform === 'win32' ?
result.disks[disk].free :
result.disks[disk].free * 1000;
}
}
}

return callback(null, free);
return callback(null, info.available);
});
};

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "storjshare-daemon",
"version": "4.0.1",
"version": "4.0.2",
"description": "daemon + process manager for sharing space on the storj network",
"main": "index.js",
"bin": {
Expand Down Expand Up @@ -69,14 +69,14 @@
"dnode": "^1.2.2",
"du": "^0.1.0",
"editor": "^1.0.0",
"fd-diskspace": "git+https://github.com/littleskunk/fd-diskspace#1e07a35e4023a222b10ff5eafcfe8a812097dea2",
"diskusage": "^0.2.3",
"fslogger": "^2.0.1",
"kad-logger-json": "^0.1.2",
"mkdirp": "^0.5.1",
"pretty-ms": "^2.1.0",
"rc": "^1.1.6",
"readable-stream": "^2.2.2",
"storj-lib": "^7.0.0",
"storj-lib": "^7.0.2",
"strip-json-comments": "^2.0.1",
"tail": "^1.2.1",
"touch": "3.1.0"
Expand Down
6 changes: 6 additions & 0 deletions script/farmer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,18 @@ const farmer = storj.Farmer(config);

config.logger.on('log', () => farmerState.lastActivity = Date.now());
config.logger.pipe(process.stdout);

farmer.join((err) => {
if (err) {
config.logger.error(err.message);
process.exit(1);
}
})
farmer.on('bridgeConnected', (bridge) => {
config.logger.info('Connected to bridge: %s', bridge.url);
});
farmer.runSpaceCheck(); // Check if we can accept offers
farmer.connectBridges();

function transportInitialized() {
return farmer.transport._requiresTraversal !== undefined
Expand Down

0 comments on commit 96d46a9

Please sign in to comment.