Skip to content

Repository files navigation

Serve Application Platform

A lightweight WebAssembly application pool and runtime.

Go Version License: MIT

Serve Application Platform is a lightweight platform for running, managing, and distributing WebAssembly (Wasm) applications. It is not a container runtime like Docker, nor an orchestration system like Kubernetes. Instead, it is an application pool – a process manager that treats each Wasm module as an independent task, sharing host resources while maintaining isolation.

  • Minimal resource usage: Each task can be limited to as low as 16 MB of memory.
  • Flexible installation: Supports local files, HTTP downloads, and BitTorrent magnets.
  • Observable: Built-in commands to list tasks (ps) and view outputs (sout).
  • Extensible: Task forking (fork), network permission controls, and custom memory limits.
  • Persistent: Node registration and configuration are saved to local JSON files.

✨ Key Features

Feature 描述
Wasm runtime Powered by wazero – pure Go, no CGO.
Node management Register (reg), list (ls), remove (rm) Wasm applications.
Task management Run (run), fork (fork), view output (sout), force-kill (kill) tasks.
Network distribution Install via BitTorrent (install -bt) or HTTP (tcon).
Resource limits Per-task memory caps (-sf) and network permission flags (-ol, -svr).
Built-in file server Quick HTTP server (svr) for testing local downloads.
Project scaffolding Generate templates for C, Go, or Python Wasm projects (mkproj).
Persistence Node states saved to sap_state.json; mirrors stored in sap_config.json.

🚀 Quick Start

Build from source

git clone https://github.com/OFFMN-SHARP/serve-app-platform.git
cd serve-app-platform
CGO_ENABLED=0 go build -o serve-app-platform.exe

Register and run your first Wasm app

  1. Start the interactive shell:
    ./serve-app-platform.exe
  2. Register a Wasm file (e.g., hello.wasm):
    reg hello.wasm
    
  3. Run it using the returned Node GUID:
    run <NodeGUID>
    
  4. Check the output:
    ps
    sout <TaskGUID>
    

Non-interactive (command-line) usage

You can also execute commands directly without entering the interactive shell. Simply pass the command and its arguments as command-line parameters.

Examples:

  • Register a Wasm file:
    serve-app-platform.exe reg hello.wasm
  • Run a Node by GUID:
    serve-app-platform.exe run <NodeGUID>
  • Install via BitTorrent:
    serve-app-platform.exe install -bt "magnet:..."
  • See all available commands (non-interactive help):
    serve-app-platform.exe help

Note: Commands that require interactive input (like exit) are not applicable in non-interactive mode. The platform will exit after completing the command.


📋 Command Reference

Command 描述
ls [-wh <keyword>] List installed Nodes
ps [-g] [-wh <keyword>] List tasks
reg <path> [-ol] Register a local or remote Wasm file
rm <NodeGUID> [-f] Remove a Node
run <NodeGUID> [-sf <size>] [-ol] [-svr] Run a Wasm application
fork <NodeGUID> [-force] Fork a new task
sout <TaskGUID> [-wlog <dir>] View task output
kill <TaskGUID> [-f] Terminate and clean up a task
install -bt <magnet> [-dir] [-p] Download and install via BitTorrent
tcon <URL> [-p <path>] Temporary download and run
chpm <URL> Change the mirror source
mkproj <name> [-golang/-py] Create a new Wasm project template
svr [-p <port>] [-dir <directory>] Start the built-in file server
about Show project information and disclaimer
help Display this help
exit Quit the platform

🧠 How It Works

The platform runs on a user-space microkernel built atop Go:

  • Each Wasm app runs in a separate goroutine, sharing the host's memory space.
  • Memory limits are enforced via wazero's MemoryConfig.
  • Network permissions are passed as environment variables (SAP_NETWORK_ENABLED, SAP_SERVER_ENABLED) to the Wasm guest.
  • Nodes (application definitions) are decoupled from tasks (running instances), enabling multi-instance forking.
  • A read‑only swap file is mounted at /swap for each task.

🛠️ Technology Stack


📄 Legal Disclaimer

This project is an independent open‑source project and is NOT affiliated with, endorsed by, or connected to SAP SE (Systems, Applications & Products in Data Processing).

The abbreviation "SAP" used in this project's history refers solely to Serve Application Platform and is not intended to infringe upon any trademark rights. For the full legal disclaimer, please see DISCLAIMER.md.


📄 License

MIT License


🤝 Contributing

Issues and pull requests are welcome. Please ensure code formatting follows gofmt and add appropriate tests.

About

Serve Application Platform—— 一个极简的、基于 Wasm 的微应用池,支持 BT/HTTP 分发、多任务并发和持久化。

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages