Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Self-hosted Azure Functions implemented in pure bash

License

NotificationsYou must be signed in to change notification settings

sbrl/shunction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⛽ Self-hostedAzure Functions ftw! (Parody)

Shunction (SHell Function) is a parody ofAzure Functions. When I first heard of Azure Functions, I knew I had to write this.

In short,shunction given a folder of function scripts, provides various mechanisms by which they can be triggered.

Getting Started

Simply clone this repository like this:

git clone git@github.com:sbrl/shunction.gitcd shunction;

Then you can call shunction like this to display some quick help on how to use it:

./shunction

Functions are, by default, looked for in./functions. A function file can be any executable with a filename in the formfunction_name.func - the shebang (the#!... bit) is respected.

CLI Arguments

Extra CLI arguments are supported:

ArgumentShort formMeaning
--config-cSpecify the location of a configuration file to load
--strip-ansinoneStrip all ANSI escape codes from the output. Useful for sending the output to a log file etc.

Configuration

Although not required, shunctioncan take a configuration file. Specify it's location with the--config CLI argument.

Such a configuration file should look something like this:

#!/usr/bin/env bashfunctions_folder="path/to/directory";
DirectiveDefault ValueMeaning
functions_folder./functionsThe location of the directory in which to find functions to execute
strip_ansifalseWhether to strip all ANSI escape codes from the output. Useful for sending the output to a log file.

Usage

Shunction supports 4 modes of operation: ad-hoc, cron, inotify, and http.

Ad-hoc

For one-off runs, usead-hoc mode.

./shunction trigger adhoc function_name

Cron

Regularly-repeating jobs can be invoked by editing your crontab withcrontab -e. Paste in something like this:

5 4***/absolute/path/to/shunction trigger cron function_name

This website is really useful for generating crontab definitions:https://crontab.guru/.

Inotify

The inotify mode allows you to run jobs when something changes on disk. Theinotifywait command is required. Shunction will automatically watch subdirectories for you.

Use it like this:

./shunction inotify"path/to/file/or/directory""function_name"

It will stick around until it is killed. Note that it will run the function once forevery event detected in the background and start listening for additional jobs immediately, so if you need to ensure only 1 instance of your program is running, try looking atthis StackOverflow answer.

Http

Finally, shunction supports listening over HTTP, though it's not advised to listen on anything more than localhost. Unlike inotify, http mode supports execution of multiple different functions, though only 1 at a time.

./shunction http bind_address port_number./shunction http 127.0.0.1 7777

Note that regular Linux rules still apply - if you want to listen on port numbers below 1024, shunction either needs to run as root (bad idea!), or you need to tell Linux that it's allowed to like this:setcap 'cap_net_bind_service=+ep' path/to/shunction.

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp