Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RAM storage, fix port aliasing using -p switch #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const os = require('os')
const fs = require('fs').promises
const repl = require('repl')
const minimist = require('minimist')
const RAM = require('random-access-memory')

const { Server, Client } = require('../')
const { migrate: migrateFromDaemon, isMigrated } = require('@hyperspace/migration-tool')
Expand All @@ -21,6 +22,7 @@ const argv = minimist(process.argv.slice(2), {
},
alias: {
host: 'h',
port: 'p',
storage: 's',
bootstrap: 'b'
}
Expand Down Expand Up @@ -67,7 +69,11 @@ async function main () {
// For now, the storage path is determined as follows:
// If ~/.hyperdrive/storage/cores exists, use that (from an old hyperdrive daemon installation)
// Else, use ~/.hyperspace/storage
const storage = argv.storage ? argv.storage : await getStoragePath()
const storage = argv['memory-only']
? getMemoryStorage()
: argv.storage ? argv.storage : await getStoragePath()

console.log(`Using '${storage}' for storage`)

const s = new Server({
host: argv.host,
Expand Down Expand Up @@ -144,6 +150,11 @@ async function getStoragePath () {
}
}

function getMemoryStorage () {
RAM.toString = () => 'RAM'
return RAM
}

function onerror (err) {
console.error(err.stack)
process.exit(1)
Expand Down