Skip to content

Builds an in-memory representation of devices using Udev and ZED.

License

Notifications You must be signed in to change notification settings

leolorenzoluis/device-scanner

 
 

Repository files navigation

device-scanner

Build Status Greenkeeper badge

This repo provides a persistent daemon That holds block devices + ZFS devices in memory.

It also provides listeners that emit changes to the daemon.

Finally, it also provides a proxy that transforms the unix domain socket events to HTTP POSTs.

Architecture

    ┌───────────────┐ ┌───────────────┐
    │  Udev Script  │ │    ZEDlet     │
    └───────────────┘ └───────────────┘
            │                 │
            └────────┬────────┘
                     ▼
          ┌─────────────────────┐
          │ Unix Domain Socket  │
          └─────────────────────┘
                     │
                     ▼
       ┌───────────────────────────┐
       │   Device Scanner Daemon   │
       └───────────────────────────┘
                     │
                     ▼
          ┌─────────────────────┐
          │ Unix Domain Socket  │
          └─────────────────────┘
                     │
                     ▼
           ┌──────────────────┐
           │ Consumer Process │
           └──────────────────┘

Development Requirements

npm comes bundled with node.js, but we recommend to use at least npm 5. If you have npm installed, you can upgrade it by running npm install -g npm.

Although is not a Fable requirement, on macOS and Linux you'll need Mono for other F# tooling like Paket or editor support.

Development setup

  • (Optional) Install ZFS via OS package manager
  • Install F# dependencies: npm run restore
  • Install JS dependencies: npm i

Building the app

Local

  • dotnet fable npm-build

Vagrant

  • Running vagrant up will setup a complete environment. It will build device-scanner, package it as an RPM and install it on the node.

    To interact with the device-scanner in real time the following command can be used to keep the stream open such that updates can be seen as the data changes:

    cat - | ncat -U /var/run/device-scanner.sock | jq

    If interaction is not required, device info can be retrieved from the device-scanner by running the following command:

    echo '"Stream"' | socat - UNIX-CONNECT:/var/run/device-scanner.sock | jq

Testing the app

  • Run the tests dotnet fable npm-test
  • Run the tests and output code coverage dotnet fable npm-coverage
  • Run the tests in watch mode:
    • In one terminal dotnet fable start
    • In a second terminal npm run test-watch
      • This will allow you to run all, or just a subset of tests, and will re-test the changed files on save.

About

Builds an in-memory representation of devices using Udev and ZED.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 50.2%
  • F# 43.8%
  • Makefile 4.8%
  • Shell 1.2%