Swarm: a basic server
A simple LevelDB-backed WebSocket and TCP-listening Swarm server (peer).
Usage
swarmd [-C|-F|-A|-R] [options] path/database-id
C, F, A, R are run modes (create, fork, access, run). The database directory name consists of the database id and peer id.
npm install -g swarm-server
# creates an empty "test" database replica (peer id 1) at ./test-1
swarmd -C --oClock=Logical ./test-1
# WebSocket-only Swarm server, runs REPL, which is good for debugging
swarmd -R ./test-1 --listen ws://localhost:8080
Options
-
-C --createcreate a database (dir name == db name)-
-n --namedatabase name (default: take from the path) -
-i --id XYreplica id (default: take from the path) -
--oXxx="Yyy"set a global database option Xxx to "Yyy" -
--OXxx="Yyy"set a scoped database option -
--0Xxx="Yyy"set a local database option override
-
-
-F --forkfork a database-
-t --to /path/dbname-YZa path for the new replica -
-i --id YZas above
-
-
-A --accessaccess a database-
-s --scan /Type#id!prefixlist all records under a prefix -
-e --erase /Type#id!prefixerase records -
-p --put fileadd ops to the database (default: read stdin) -
-v --vvprint the version vector -
-g --get /Type#idprint the object's state -
--OXxx, --0Xxxedit database options (as above)
-
-
-U --useradd/remove/list users/clients-
-a --add loginadd a user (take the password from stdin) -
-r --remove login -
-l --list
-
-
-R --runrun a database (the default)-
-l --listen scheme:urllisten for client conns on URL-
-stdin (default) -
ws://hostname:portWebSocket -
tcp://11.22.33.44:5555TCP
-
-
-c --connect scheme:urlconnect to a peer -
-e --exec script.jsexecute a script once connected -
-r --replstart REPL -
-d --daemondaemonize -
-xexit when done -
-f --filtergrep log events (e.g.-f /Swarm.on.off)
-
Database options
- Globals (relayed to every replica)
-
DBIdSchemereplica id scheme (e.g.--oIdScheme=0280) -
Clockclock mode (Logical,Hybrid) -
ClockLenminimum time value length (e.g. 6 for1GDBdW)
-
- Scopeds (relayed to clients, but not peers)
- Locals (not relayed)
-
Listenlisten url (e.g.-0Listen=wss://swarmdb.net:1234) -
Connectpeer's url (e.g.-0Connect=tcp://1.2.3.4:5678)
-
for a CLI client, see swarm-client.