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

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 pratikbin 0
Owner
Antoine Grondin
Antoine Grondin
ap 是一个 shell 工具,可以让其它 shell 命令的输出能够自动进入交互翻页模式

ap -- auto-pager ap 是一个 shell 工具,可以让其它 shell 命令的输出能够自动进入交互翻页模式。 ap 由两部分组成,一个 Go 语言编写的二进制程序,负责捕获命令的输出并支持翻页, 和一组 shell 脚本,负责为用户指定的命令清单创建与之同名的 wrapper。 经

flw 12 Apr 12, 2022
Create new commands from your shell history or terminal.

overdub Create new commands from your shell history or terminal. TODO list for initial release Filter out unlikely commands (e.g. package managers) fr

Michael Zalimeni 6 Aug 9, 2022
Node is where client will send data to, create block send to miner, create block send to parent and receive tick from validator and do validate

Node Receive Tick from validator Validate POH of tick send result to validator Receive confirm block from validator Send Checked block to validator Ho

Hieu Phan 0 Dec 31, 2021
Tool for shell commands execution, visualization and alerting. Configured with a simple YAML file.

Sampler. Visualization for any shell command. Sampler is a tool for shell commands execution, visualization and alerting. Configured with a simple YAM

Alexander Lukyanchikov 10.4k Aug 18, 2022
Blocking CMD shell interaction tool.

CliToolkit Blocking command line shell interaction tool. CliToolkit is a small cmd package for Go cmd shell interaction application. Installation # do

Aeoluze 2 Oct 28, 2021
Go Coverage in Shell: a tool for exploring Go Coverage reports from the command line

Go Coverage in Shell: a tool for exploring Go Coverage reports from the command line

Yury Fedorov 173 Aug 12, 2022
Just a simple CLI tool to group dependabot PRs by dependency and merge them.

Dependabotbot Have you been the victim of a lodash update? Has your notification page in Github been assaulted by needing to update a patch version of

Chris Griffing 22 Jun 30, 2022
gomUP is a tool to keep track of outdated dependencies and upgrade them to the latest version

gomUP ?? gomUP is a tool to keep track of outdated dependencies and upgrade them to the latest version. Designed for monorepo Go projects and Go proje

Alihan Doğuş Yalçın 20 Jul 26, 2022
🎀 a nice lil shell for lua people made with go and lua

Hilbish ?? a nice lil shell for lua people made with go and lua It is currently in a mostly beta state but is very much usable (I'm using it right now

Hilbis Development 251 Aug 16, 2022
ReverseSSH - a statically-linked ssh server with reverse shell functionality for CTFs and such

ReverseSSH A statically-linked ssh server with a reverse connection feature for simple yet powerful remote access. Most useful during HackTheBox chall

null 597 Aug 17, 2022
Dinogo is an CLI framework for build terminal and shell applications in Go.

dinogo Dinogo is an CLI framework for build terminal and shell applications in Go. Features Cross Platform Fast and efficient Keyboard API Enable/Disa

Mertcan Davulcu 11 Jul 26, 2022
Testing local and remote shell commands in Go

Testing local and remote shell commands in Go. This is an (intentionally simplified) example of how unix shell commands can be unit-tested in Go. The

Anton 5 Nov 30, 2021
A powerful modern CLI and SHELL

Grumble - A powerful modern CLI and SHELL There are a handful of powerful go CLI libraries available (spf13/cobra, urfave/cli). However sometimes an i

梁辰风 0 Dec 30, 2021
The extremely customizable and themeable shell prompt.

kitch-prompt Kitch-prompt is a cross-platform tool for displaying a shell prompt, which can be extensively customized both in terms of what is shown,

Jason Walton 2 Jul 14, 2022
A simple CLI tool that identifies duplicate JARS in a directory. It can remove them also if desired.

Mendix Userlib Cleaner This little utility can be used to identify and clean duplicate JARs. It was created mainly for Mendix apps due to lack of form

CINAQ Internet Technologies 14 Aug 10, 2022
🧑‍💻📊 Show off your most used shell commands

tsukae ??‍?? ?? Tsukae, 使え - means use in Japanese (so it refers to commands that you use) Built on top of termui and cobra Big shoutout to jokerj40 f

Ilya Revenko 432 Aug 1, 2022
A goroutine monitor to keep track of active routines from within your favorite shell.

roumon A goroutine monitor to keep track of active routines from within your favorite shell. Features Track live state of all active goroutines Termin

Armin Becher 89 Aug 18, 2022
Shelby is a fast ⚡️ , lightweight ☁️ , minimal✨, shell prompt written in Go.

Shelby is a fast ⚡️ ,lightweight ☁️ ,minimal ✨ , shell prompt written in Pure Go. Installation Follow the steps below(Linux and macOS), and Post Insta

Athul Cyriac Ajay 164 Aug 2, 2022
A multiple reverse shell sessions/clients manager via terminal written in go

A multiple reverse shell sessions/clients manager via terminal written in go

Krisna Pranav 12 Feb 23, 2022