Self-hosted functions (Lambda-like) runtime and CLI
Project description
fnctl
A tiny, self-hosted functions (Lambda-like) runtime and CLI. Create small functions, run a local HTTP gateway to invoke them via GET, POST, etc., and manage per-function logs.
Installation
PyPI Installation
Use the package manager pip to install fnctl.
pip install fnctl
pipx (isolated CLI install)
pipx installs CLI tools into dedicated virtual environments and exposes their entry points on your PATH.
pipx upgrade fnctl
Usage
Create a function
# Check version
fnctl --version
# For more details use -h
fnctl -h # Shows list of commands
fnctl serve -h # Show arguments for serve function
# Start the server (foreground, Ctrl+C to stop)
fnctl serve --host 127.0.0.1 --port 8080
# Or start in background (returns to shell)
fnctl serve --host 127.0.0.1 --port 8080 &
# Create a Python function
fnctl create hello --lang python
# Confirm that new function has been created
fnctl list
# Test that it can be called
curl -s http://127.0.0.1:8080/fn/hello
curl -s "http://127.0.0.1:8080/fn/hello?name=dev"
# To destroy a function
fnctl destroy hello
# Add --purge-logs to remove its logs
fnctl destroy hello --purge-logs
Start/Restart without server logs
Silence all HTTP server output while keeping per‑function logs untouched.
- Start (no logs):
# With PID file
fnctl serve --quiet --host 127.0.0.1 --port 8080 >/dev/null 2>&1 & echo $! >/tmp/fnctl.pid
# Without PID file
fnctl serve --quiet --host 127.0.0.1 --port 8080 >/dev/null 2>&1 &
- Restart (no logs):
# With PID file
([ -f /tmp/fnctl.pid ] && kill "$(cat /tmp/fnctl.pid)" || true; \
fnctl serve --quiet --host 127.0.0.1 --port 8080 >/dev/null 2>&1 & echo $! >/tmp/fnctl.pid)
# Without PID file
(pkill -f 'fnctl serve' || true) && fnctl serve --quiet --host 127.0.0.1 --port 8080 >/dev/null 2>&1 &
- Stop:
# With PID file
kill "$(cat /tmp/fnctl.pid)" || true; rm -f /tmp/fnctl.pid
# Without PID file
pkill -f 'fnctl serve' || true
Notes:
--quietsuppresses HTTP access logs; redirection to/dev/nullhides the startup line and any stderr.- Function logs are separate and can be toggled per function:
fnctl disable-logs <name>/fnctl enable-logs <name>
Start/Restart with server logs
If you want to see HTTP access logs in your terminal, do not use --quiet and do not redirect output to /dev/null.
- Start (with logs):
# Foreground (prints logs; Ctrl+C to stop)
fnctl serve --host 127.0.0.1 --port 8080
# Background (prints logs in current terminal session)
fnctl serve --host 127.0.0.1 --port 8080 & echo $! >/tmp/fnctl.pid
# Foreground, save logs to file (and print)
fnctl serve --host 127.0.0.1 --port 8080 2>&1 | tee -a ~/fnctl.http.log
# Background, append logs to file and save PID
fnctl serve --host 127.0.0.1 --port 8080 >>~/fnctl.http.log 2>&1 & echo $! >/tmp/fnctl.pid
- Restart (with logs):
# With PID file
([ -f /tmp/fnctl.pid ] && kill "$(cat /tmp/fnctl.pid)" || true; \
fnctl serve --host 127.0.0.1 --port 8080 >>~/fnctl.http.log 2>&1 & echo $! >/tmp/fnctl.pid)
# Without PID file
(pkill -f 'fnctl serve' || true) && fnctl serve --host 127.0.0.1 --port 8080 >>~/fnctl.http.log 2>&1 &
# Follow the log
tail -f ~/fnctl.http.log
Function location
~/.fnctl/
functions/
hello/
fnctl.json # function config
main.py # template with handler(event, context)
logs/
hello.log # logs for hello function
Edit your function
- Python handler: edit
~/.fnctl/functions/<name>/main.py(default entrypoint ismain:handler). - Config: edit
~/.fnctl/functions/<name>/fnctl.jsonto changeentrypoint, enable/disablelogging, or setcommandfor exec functions. - Reload: the server reloads the Python module automatically when the file changes; just save and curl again.
Logging
Enable/disable per function via config or CLI:
fnctl enable-logs <name>fnctl disable-logs <name>
Inspect logs:
fnctl logs <name>or follow with-f
Data directory (FNCTL_HOME)
- By default, fnctl stores data under
~/.fnctl. - Override per shell or process:
export FNCTL_HOME=/path/to/custom/dir
fnctl create demo
fnctl serve --quiet --host 127.0.0.1 --port 8080 &
Contributing
Local Installation
# Clone repository to local machine
git clone https://github.com/vedantm8/fnctl.git
cd fnctl
# Necessary libraries on Debian-based environment
apt-get install -y python3 python3-venv python3-pip ca-certificates curl
# Create a virtual environment
python3 -m venv /opt/fnctl-venv
. /opt/fnctl-venv/bin/activate
# Install fnctl
python -m pip install --upgrade pip
python -m pip install -e .
Testing
- Run all tests with pytest:
pip3 install pytest
pytest -q
-
Tests use a temporary
FNCTL_HOMEso they do not touch your real~/.fnctl. -
The suite covers creating, listing, invoking, and destroying functions (with and without purging logs).
-
Show
print()output during tests (optional):
pytest -s -q # disable capture to see prints live
# or
pytest -q --capture=tee-sys # show prints while also capturing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fnctl-0.1.1.tar.gz.
File metadata
- Download URL: fnctl-0.1.1.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b416ab4cb443f95edaf5acd166820e6b68e5db49a4c35fbb4e460514a912e3ad
|
|
| MD5 |
9214d34f5e8746cc36a2e45ba976dd74
|
|
| BLAKE2b-256 |
a6e8ffa9a453467dc928d292e7b9377b3aed8cb988941f3970604ee429ac8c17
|
File details
Details for the file fnctl-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fnctl-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1e528ab873cd38a9c9abf37fac4b2f50adfdfc349a793b3ad773ea857cec094
|
|
| MD5 |
3965efc5def04e78446bd899709d95e8
|
|
| BLAKE2b-256 |
f6a9463869f11a05088e6aff06436510ed806258696c8e243de36d82f5e41082
|