{"id":49822132,"url":"https://github.com/folk-project/folk-core","last_synced_at":"2026-05-14T13:02:05.794Z","repository":{"id":356701967,"uuid":"1232424637","full_name":"Folk-Project/folk-core","owner":"Folk-Project","description":"Core Rust workspace for Folk: protocol, plugin API, server core, pipe and fork runtimes","archived":false,"fork":false,"pushed_at":"2026-05-13T10:10:24.000Z","size":178,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"develop","last_synced_at":"2026-05-13T12:40:03.269Z","etag":null,"topics":["application-server","folk","msgpack","php","rust","unix-socket","worker-pool"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Folk-Project.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-05-07T23:23:20.000Z","updated_at":"2026-05-13T10:10:39.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Folk-Project/folk-core","commit_stats":null,"previous_names":["folk-project/folk-core"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Folk-Project/folk-core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Folk-Project%2Ffolk-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Folk-Project%2Ffolk-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Folk-Project%2Ffolk-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Folk-Project%2Ffolk-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Folk-Project","download_url":"https://codeload.github.com/Folk-Project/folk-core/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Folk-Project%2Ffolk-core/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33026049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["application-server","folk","msgpack","php","rust","unix-socket","worker-pool"],"created_at":"2026-05-13T12:07:21.437Z","updated_at":"2026-05-14T13:02:05.508Z","avatar_url":"https://github.com/Folk-Project.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# folk-core\n\nRust-based application server for PHP. Long-lived workers, fork-based runtime with warm OPcache, plugin ecosystem.\n\n\u003e **Status:** in active development. See [folk-spec](https://github.com/Folk-Project/folk-spec) for the roadmap.\n\n## Requirements\n\n- Rust 1.85+\n- PHP 8.2+ with `ext-msgpack`\n- Unix-like OS (Linux or macOS)\n\n## Installation\n\n```toml\n# Cargo.toml\nfolk-core = \"0.1\"\n```\n\nFor most users, build a custom binary with [folk-builder](https://github.com/Folk-Project/folk-builder) instead of depending on this crate directly.\n\n## Quick start\n\n1. Create a minimal `folk.toml`:\n\n```toml\n[server]\nruntime = \"pipe\"\nrpc_socket = \"/tmp/folk.sock\"\nshutdown_timeout = \"30s\"\n\n[workers]\nscript = \"vendor/bin/folk-worker\"\nphp = \"php\"\ncount = 4\n\n[log]\nfilter = \"info\"\nformat = \"text\"\n```\n\n2. Start the server:\n\n```bash\nfolk serve --config folk.toml\n```\n\n3. Expected startup output:\n\n```\nINFO folk server starting version=0.1.0 workers=4 runtime=pipe\nINFO worker pool started\nINFO all plugins booted plugins=[\"http\", \"metrics\"]\nINFO admin RPC server listening socket=/tmp/folk.sock\n```\n\n4. Stop with `Ctrl-C` or `SIGTERM`. The server drains gracefully:\n\n```\nINFO received SIGTERM\nINFO shutdown signal received; draining\nINFO http shutting down\nINFO metrics shutting down\nINFO folk server stopped\n```\n\n## Configuration\n\nAll fields can be overridden with environment variables using the `FOLK_` prefix (e.g., `FOLK_WORKERS_COUNT=8`). Config is loaded as: defaults → `folk.toml` → environment variables.\n\n### `[server]`\n\n| Key | Type | Default | Description |\n|-----|------|---------|-------------|\n| `runtime` | `\"pipe\"` \\| `\"fork\"` | `\"pipe\"` | Worker runtime. `pipe` spawns via execve; `fork` uses a prefork master with warm OPcache. |\n| `rpc_socket` | `String` | `\"/tmp/folk.sock\"` | Unix socket path for the admin RPC server. |\n| `shutdown_timeout` | `Duration` | `\"30s\"` | Maximum time to wait for graceful shutdown before forcing exit. |\n\n### `[workers]`\n\n| Key | Type | Default | Description |\n|-----|------|---------|-------------|\n| `script` | `String` | `\"vendor/bin/folk-worker\"` | Path to the PHP worker entry script. |\n| `php` | `String` | `\"php\"` | PHP binary path. |\n| `count` | `usize` | `4` | Number of worker processes. |\n| `max_jobs` | `u64` | `1000` | Requests a worker handles before being recycled. |\n| `ttl` | `Duration` | `\"3600s\"` | Maximum worker lifetime before recycling. |\n| `max_memory_mb` | `u64` | `256` | RSS memory limit (MB) before recycling. |\n| `exec_timeout` | `Duration` | `\"30s\"` | Per-request execution timeout. |\n| `boot_timeout` | `Duration` | `\"30s\"` | Timeout for worker to send `control.ready`. |\n\n### `[log]`\n\n| Key | Type | Default | Description |\n|-----|------|---------|-------------|\n| `filter` | `String` | `\"info\"` | Log level filter. Supports per-module: `folk_core=trace`. Overridden by `RUST_LOG`. |\n| `format` | `\"text\"` \\| `\"json\"` \\| `\"pretty\"` | `\"text\"` | Log output format. Use `json` for log aggregators. |\n\n## How it works\n\nFolk supervises long-lived PHP processes and dispatches HTTP requests, jobs, and gRPC calls to them over a length-prefixed MessagePack-RPC protocol on Unix sockets.\n\n### Runtimes\n\n**Pipe runtime** (default) — spawns each PHP worker via `execve` with a Unix socketpair. Each worker is independent and stateless. Workers communicate over two file descriptors: FD 3 (task channel) and FD 4 (control channel).\n\n**Fork runtime** — a prefork master boots the PHP framework once, warming OPcache and autoload caches. Workers are then `fork()`-ed from the master, inheriting the warm state. This eliminates cold-start overhead per worker. Requires `ext-pcntl`.\n\n### Worker lifecycle\n\nWorkers cycle through states: **Spawning** → **Idle** → **Busy** → back to Idle, until recycled. A worker is recycled when it exceeds `max_jobs`, `ttl`, or `max_memory_mb`. Recycled workers are replaced immediately.\n\n### Shutdown behavior\n\nOn `SIGTERM` or `SIGINT`:\n\n1. The shutdown signal broadcasts to all components.\n2. Plugins shut down in **reverse registration order**.\n3. Workers finish in-flight requests (graceful drain).\n4. If drain exceeds `shutdown_timeout`, remaining tasks are aborted.\n5. The admin RPC socket is removed and the process exits.\n\n### Plugin system\n\nPlugins are compiled into the binary via [folk-builder](https://github.com/Folk-Project/folk-builder). Each plugin depends only on [folk-api](https://github.com/Folk-Project/folk-api), not on folk-core. Plugins boot in registration order and shut down in reverse. See [folk-api](https://github.com/Folk-Project/folk-api) for the plugin authoring guide.\n\n### Repository layout\n\n```\ncrates/\n├── folk-protocol/     wire format (RpcMessage, FrameCodec)\n├── folk-core/         server core (worker pool, plugin registry)\n├── folk-runtime-pipe/ runtime: spawn via execve + Unix socketpair\n└── folk-runtime-fork/ runtime: warm OPcache via prefork\nfolk/                  reference binary (folk serve)\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffolk-project%2Ffolk-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffolk-project%2Ffolk-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffolk-project%2Ffolk-core/lists"}