GithubHelp home page GithubHelp logo

haroldvera / erlang-systools Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sdanzan/erlang-systools

0.0 2.0 0.0 39 KB

Erlang wrapper around various utilities (inotifywait, pigz, [md5/sha1/sha256...]sum, etc.)

License: GNU Lesser General Public License v3.0

Makefile 2.04% Erlang 97.96%

erlang-systools's Introduction

Erlang Systools

A collection of utility modules for system related stuff.

  • inotifywait: a wrapper around the inotifywait utility.
  • pigz: a wrapper around parallel gzip pigz.
  • checksum: checksum over files.
  • shell_utils: utilities for better communication with external shell.
  • plimiter: limiting the number of launched processes.

Inotifywait Wrapper

A simple wrapper around Linux inotify using inotifywait from inotify-tools.

Wrappping is done via a port spawning an external inotifywait command in monitor mode. You simply listen to messages from the wrapper to get inotify events. You can also start an event manager and use a gen_event behaviour to subscribe to events.

The module should work on any box where inotifywait and a standard posix sh shell are available.

Flow

start spawns a wrapper erlang process which will check passed options and then spawns a inotifywait external process through a plain erlang port (using erlang:open_port/2 with the spawn option). The wrapper process receives inotifywait standard output as messages from the port, parses them and sends them forward as structured messages to the process that invoked start in the first place.

Why not a custom port written in C or a port driver?

Because I wanted to experiment with the idea of using a plain port to an external process and wanted to keep the code small. Besides there already exists an erlang inotify module built around the inotify C API (for instance there)

Pigz

Erlang wrapper around the pigz program. Setting compression level and degree of parallelism are allowed. Wrapping is done through a process waiting for compression commands.

Checksums

Checksums on files (md5, sha1, sha256, sha512) implemented in Erlang and also as wrapper functions around the xxxsum utilities family.

Shell Utils

Utility functions for communication with external (posix) shell (string escaping and stuff like that).

PLimiter

Provides a mean to limit the number of concurrent processes, like a worker pool but much simpler.

The module provides the following functions:

  • start: creates a process limiter with a given maximum of concurrent processes. The limiter is itself implemented as a process.
  • start_link: creates a process limiter linked to the caller.
  • stop: destroys a process limiter. Only its creator can destroy a limiter. Processes already waiting to be run will be run before the limiter actually stops.
  • spawn: spawns a new process through the given limiter. If max number of concurrent processes if reached, the process will be spawned when the number of processes falls back below the limit.
  • spawn_link: same as spawn but the process will be linked to the caller.

erlang-systools's People

Contributors

sdanzan avatar haroldvera avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.