A shell tool to create counting semaphores, acquire them and release them.

Related tags

semaphore
Overview

semaphore

A shell tool to create counting semaphores, acquire them and release them. This is useful if you want to e.g. run no more than N out of M commands in parallel.

usage

Create a semaphore of size 10 for a job that will fetch URLs in parallel.

semaphore create --name fetch-many-urls --size 10

Then before launching each job, acquire the semaphore:

semaphore acquire --name fetch-many-urls

Do your job, and when you're done:

semaphore release --name fetch-many-urls

example

#!/usr/bin/env bash

lockname=$(uuidgen)
semaphore create --name ${lockname} --size 2

function fetch_url() {
    local url=${1}
    semaphore acquire --name ${lockname}
    echo "fetching URL ${1}"
    sleep 1
    semaphore release --name ${lockname}
}

for ((i=0; i<=10; i++)); do
    fetch_url "http://url.number.${i}" &
done

wait $(jobs -p)

using it

Grab a release or :

on macOS

brew tap aybabtme/homebrew-tap
brew install semaphore

license

The tool here is MIT. The code is 99.9% powered by a fork of bitbucket.org/avd/go-ipc, which is Apache 2.

Issues
  • Thank you issue

    Thank you issue

    This is exactly what I was looking for earlier, and I found gnu parallel which was not the same, so I have to band my script to use it, but now I can use this instead of gnu parallel. Close this on your acknowledgment.

    PS: I can't find your Twitter handle so created issue sorry

    Thank you

    opened by pratikbalar 0
Owner
Antoine Grondin
Antoine Grondin
🐙 Yeoman Generator for Golang Microservices.

Yeoman Generator for Golang Microservices Documentation Usage Install Yeoman $ npm install -g yo Install with NPM $ npm install generator-goapi $ yo

Ahmed 7 Sep 26, 2021
Handy little CLI for interacting with OCI data

oci-tool Handy little CLI for interacting with OCI data Installation go get github.com/csweichel/oci-tool I use Gitpod for developing this tool; you s

Christian Weichel 10 Oct 8, 2021
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.

dasel Dasel (short for data-selector) allows you to query and modify data structures using selector strings. Comparable to jq / yq, but supports JSON,

Tom Wright 1.6k Oct 18, 2021
CraftTalk Command Line Tool helps with managing CraftTalk releases on baremetal instances

ctcli - CraftTalk Command Line Tool Commands help Shows help version Shows version init Initializes specified root directory as a ctcli dir. ctcli --r

CraftTalk 10 Jul 5, 2021
🔥 [WIP] Interactive Jira Command Line

JiraCLI Interactive Jira CLI ?? This project is still a work in progress ?? This tool mostly focuses on issue search and navigation at the moment. How

Ankit Pokhrel 212 Oct 19, 2021
✨ Create a new production-ready project with backend, frontend and deploy automation by running one CLI command!

✨ Create a new production-ready project with backend, frontend and deploy automation by running one CLI command!

Create Go App 992 Oct 20, 2021
gon is a simple, no-frills tool for signing and notarizing your CLI binaries for macOS

Sign, notarize, and package macOS CLI tools and applications written in any language. Available as both a CLI and a Go library.

Mitchell Hashimoto 1.1k Oct 12, 2021
A CLI which automates semver versioning.

Semverbot A CLI which automates semver versioning based on git information. Why Semverbot? There are several reasons why you should consider using sbo

null 53 Oct 13, 2021
Fast, realtime regex-extraction, and aggregation into common formats such as histograms, numerical summaries, tables, and more!

rare A file scanner/regex extractor and realtime summarizor. Supports various CLI-based graphing and metric formats (histogram, table, etc). Features

Chris LaPointe 119 Oct 11, 2021
git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.

Table of contents Introduction Reference Contributing Introduction Overview git-xargs is a command-line tool (CLI) for making updates across multiple

Gruntwork 496 Oct 15, 2021
A command-line tool and library for generating regular expressions from user-provided test cases

Table of Contents What does this tool do? Do I still need to learn to write regexes then? Current features How to install? 4.1 The command-line tool 4

Peter M. Stahl 4.6k Oct 14, 2021
This tool is a CLI-interactive tool for TA who use eeclass platform

NTHU eeclass TA helper. This tool is a CLI-interactive tool for TA who use eeclass platform. It helps TA to download all the submitted homework, and use CSV to record the score and comment, and upload CSV score directly to the eeclass platform with just 2 Enter key!

Bo-Wei Chen 0 Oct 22, 2021
An open-source GitLab command line tool bringing GitLab's cool features to your command line

GLab is an open source GitLab CLI tool bringing GitLab to your terminal next to where you are already working with git and your code without switching

Clement Sam 1.5k Oct 25, 2021
`tfx` is a standalone CLI for Terraform Cloud and Terraform Enterprise.

TFx CLI tfx is a standalone CLI for Terraform Cloud and Terraform Enterprise. The initial focus of tfx is to execute the API-Driven workflow for a Wor

Tom Straub 32 Oct 11, 2021
Declarative CLI Version manager. Support Lazy Install and Sharable configuration mechanism named Registry. Switch versions seamlessly

aqua Declarative CLI Version manager. Support Lazy Install and Sharable configuration mechanism named Registry. Switch versions seamlessly. Index Slid

Shunsuke Suzuki 9 Oct 23, 2021
Soren L. Hansen 1.4k Oct 25, 2021
This is a command line application to manage and fine-tune Time Machine exclude paths.

heptapod This is a command line application to manage and fine-tune Time Machine exclude paths. This repository is a WIP! The advertised functionality

Gergő Törcsvári 1 Oct 13, 2021
go program that installs and customizes ohmyzsh tmux vim via various plugins and other nice to haves

Pimp-My-Shell Table of Contents Pimp-My-Shell Install Usage About Resources Tmux Hotkeys VIM Hotkeys Adjusting Custom Aliases Mac Fix Terminal bind ke

null 2 Oct 20, 2021
CONTRIBUTIONS ONLY: A Go (golang) command line and flag parser

CONTRIBUTIONS ONLY What does this mean? I do not have time to fix issues myself. The only way fixes or new features will be added is by people submitt

Alec Thomas 3.1k Oct 18, 2021