Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Commit feeb34d

Browse files
committed
fixed bugs + rewritten docs + made zinit proxy available through zinit proxy -a <ADDR> command
1 parent dd3c23c commit feeb34d

File tree

24 files changed

+509
-3360
lines changed

24 files changed

+509
-3360
lines changed

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ path = "src/lib.rs"
4444
[[bin]]
4545
name = "zinit"
4646
path = "src/main.rs"
47-
[[bin]]
48-
name = "testapp"
49-
path = "src/bin/testapp.rs"
50-
[[bin]]
51-
name = "zinit-http"
52-
path = "src/bin/zinit-http.rs"
47+
# [[bin]]
48+
# name = "testapp"
49+
# path = "src/bin/testapp.rs"
50+
# [[bin]]
51+
# name = "zinit-http"
52+
# path = "src/bin/zinit-http.rs"
5353

README.md

Lines changed: 27 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
# Zinit - A Process Manager
1+
# Zinit [![Rust](https://github.com/threefoldtech/zinit/actions/workflows/rust.yml/badge.svg)](https://github.com/threefoldtech/zinit/actions/workflows/rust.yml)
22

3-
Zinit is a process manager designed to manage services and their lifecycle. It provides both a Unix socket interface and an HTTP API for interacting with the process manager.
3+
Zinit is a lightweight PID 1 replacement inspired by runit, written in Rust using Tokio for async I/O. It provides both a Unix socket interface and an HTTP API for interacting with the process manager.
44

5-
## Components
5+
### Key Features
66

7-
Zinit now consists of two separate binaries:
7+
- **Service Management**: Ensures configured services are up and running at all times
8+
- **Dependency Handling**: Supports service dependencies for proper startup ordering
9+
- **Simple Control Interface**: Provides an intuitive CLI to add, start, stop, and monitor services
10+
- **Container Support**: Can run in container mode with appropriate signal handling
11+
- **Configurable Logging**: Multiple logging options including ringbuffer and stdout
812

9-
1. **zinit** - The core process manager that handles service lifecycle management
10-
2. **zinit-http** - An HTTP proxy that forwards JSON-RPC requests to the Zinit Unix socket
13+
## Installation
1114

12-
This separation allows for more flexibility and reduced resource usage when the HTTP API is not needed.
15+
Click [here](docs/installation.md) for more information on how to install Zinit.
1316

1417
## Usage
1518

@@ -29,100 +32,38 @@ zinit start <service-name>
2932
zinit stop <service-name>
3033
```
3134

32-
### HTTP Proxy (zinit-http)
33-
3435
```bash
3536
# Start the HTTP proxy on the default port (8080)
36-
zinit-http --socket /var/run/zinit.sock
37-
38-
# Start the HTTP proxy on a custom port
39-
zinit-http --socket /var/run/zinit.sock --port 3000
37+
zinit proxy
4038
```
4139

42-
## JSON-RPC API
43-
44-
The HTTP proxy provides a JSON-RPC 2.0 API for interacting with Zinit. You can send JSON-RPC requests to the HTTP endpoint:
45-
46-
```bash
47-
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"service.list","params":{}}' http://localhost:8080/
48-
```
40+
More information about all the available commands can be found [here](docs/cmd.md).
4941

50-
## Building from Source
42+
### Service Configuration
5143

52-
```bash
53-
# Build both binaries
54-
cargo build --release
44+
Zinit uses YAML files for service configuration. Here's a basic example:
5545

56-
# The binaries will be available in target/release/
46+
```yaml
47+
# Service configuration (e.g., /etc/zinit/myservice.yaml)
48+
exec: "/usr/bin/myservice --option value" # Command to run (required)
49+
test: "/usr/bin/check-myservice" # Health check command (optional)
50+
oneshot: false # Whether to restart on exit (default: false)
51+
after: # Services that must be running first (optional)
52+
- dependency1
53+
- dependency2
5754
```
5855
59-
# Zinit [![Rust](https://github.com/threefoldtech/zinit/actions/workflows/rust.yml/badge.svg)](https://github.com/threefoldtech/zinit/actions/workflows/rust.yml)
60-
61-
A lightweight PID 1 replacement inspired by runit, written in Rust using Tokio for async I/O.
62-
63-
## Overview
64-
65-
Zinit is a service manager designed to be simple, lightweight, and reliable for both system services and container environments. It acts as an init system (PID 1) but focuses only on essential service management functionality.
66-
67-
### Key Features
68-
69-
- **Service Management**: Ensures configured services are up and running at all times
70-
- **Dependency Handling**: Supports service dependencies for proper startup ordering
71-
- **Simple Control Interface**: Provides an intuitive CLI to add, start, stop, and monitor services
72-
- **Container Support**: Can run in container mode with appropriate signal handling
73-
- **Configurable Logging**: Multiple logging options including ringbuffer and stdout
74-
75-
## Documentation
76-
77-
Comprehensive documentation is available in the [docs](docs) directory:
78-
79-
- [Command Line Interface](docs/README.md)
80-
- [Implementation Details](docs/implementation.md)
81-
- [API Protocol](docs/protocol.md)
82-
83-
## Quick Start
84-
85-
### Installation
86-
87-
```bash
88-
# Build from source
89-
make
90-
91-
# Install the binary
92-
sudo cp target/x86_64-unknown-linux-musl/release/zinit /usr/local/bin/
93-
```
56+
For more information on how to configure service files, see the [service file reference](docs/services.md) documentation.
9457
95-
### Testing with Docker
58+
### JSON-RPC API
9659
97-
To quickly try zinit in a container environment:
60+
The HTTP proxy provides a JSON-RPC 2.0 API for interacting with Zinit. You can send JSON-RPC requests to the HTTP endpoint you provided to the proxy:
9861
9962
```bash
100-
# Build the test docker image
101-
make docker
102-
103-
# Run the container
104-
docker run -dt --device=/dev/kmsg:/dev/kmsg:rw zinit
63+
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"service_list","params":{}}' http://localhost:8080/
10564
```
10665
107-
The test image automatically starts Redis and OpenSSH services.
108-
109-
## Building from Source
110-
111-
### Requirements
112-
113-
- Rust (cargo) - version 1.46.0 or later
114-
- musl and musl-tools packages
115-
- GNU Make
116-
117-
### Build Instructions
118-
119-
```bash
120-
# Standard build
121-
make
122-
123-
# For development/debug
124-
make dev
125-
```
66+
See the [OpenRPC specs](openrpc.json) for more information about available RPC calls to interact with Zinit.
12667
12768
## License
12869

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ FROM ubuntu:18.04
22

33
RUN mkdir -p /etc/zinit
44
ADD zinit /sbin/zinit
5-
ADD zinit-http /sbin/zinit-http
5+
# ADD zinit-http /sbin/zinit-http
66

77
ENTRYPOINT ["/sbin/zinit", "init"]

docs/README.md

Lines changed: 0 additions & 67 deletions
This file was deleted.

docs/api/openrpc.md

Lines changed: 0 additions & 129 deletions
This file was deleted.

0 commit comments

Comments
 (0)