https://github.com/codjix/codjixd
A lightweight and flexible service manager for Linux systems and Docker containers.
https://github.com/codjix/codjixd
initd openrc service-manager systemd
Last synced: 10 months ago
JSON representation
A lightweight and flexible service manager for Linux systems and Docker containers.
- Host: GitHub
- URL: https://github.com/codjix/codjixd
- Owner: codjix
- License: mit
- Created: 2025-01-07T23:52:18.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-01-11T20:14:18.000Z (12 months ago)
- Last Synced: 2025-01-21T05:16:10.333Z (12 months ago)
- Topics: initd, openrc, service-manager, systemd
- Language: Shell
- Homepage: https://dub.sh/codjixd
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README
# Codjixd
**Codjixd** is a lightweight and flexible service manager for Linux systems and Docker containers.
## Features
- **Start, Stop, Restart**: Manage services with simple commands.
- **Status, List**: Simple metrics-like status, list all services.
- **Defination, Configs**: Easy to define and configure services.
- **Dependency Management**: Automatically start dependent services.
- **Health Checks**: Define custom health checks for services.
- **Log Rotation**: Automatically rotate logs for better management.
- **Run anywhere**: As a plain script it can run on any Linux system.
## Installation
### Requirements
- It requires `bash` to run. Make sure you have it installed.
- On busybox-based systems, you need to install the full:
- `procps` it is required to work properly.
- `less` it is optional to get live logs.
```bash
apk add bash procps less
```
### Shell Script
```bash
# 1. Get the script:
wget https://dub.sh/codjixd -O codjixd.sh
# 2. Make it executable:
chmod +x codjixd.sh
# 3. Add script to $PATH:
sudo mv codjixd.sh /usr/bin/codjixd
# 4. Final setup:
mkdir -p /opt/codjixd/services
sudo chown -R $USER /opt/codjixd
```
### Docker Image
```bash
docker pull codjix/codjixd:latest
```
## Usage
```
Usage: codjixd []
Commands:
start Start a service
stop Stop a service
restart Restart a service
kill Kill a service and its dependencies
status Show status and metrics for a service
logs Tail logs for a service
list, ls List all available services
version Show version information
help Show this help message
Options:
-v, --version Show version information
-h, --help Show this help message
```
## Configuration
Codjixd uses a configuration file located at `/etc/codjixd.conf`. You can customize the following variables:
```ini
BASE_DIR="/opt/codjixd" # Base directory for logs, PIDs, and services
LOG_DIR="$BASE_DIR/logs" # Directory for service logs
PID_DIR="$BASE_DIR/pids" # Directory for PID files
SERVICES_DIR="$BASE_DIR/services" # Directory for service scripts
```
## Service Definition
To create a service for Codjixd, follow these steps:
1. Create a Service Script:
- Place your service script in the `services` directory (default: /opt/codjixd/services).
- `Serivce name` is considered as the script name without ".sh" extension so keep it simple.
- The script must has a `start_fn` function, which contains the logic to start the service.
- Optionally, you can define a `health_check` function for custom health checks and a `depend_on` array for service dependencies.
2. Example Service Script:
```bash
#!/bin/bash
# Dependencies (optional)
depend_on=("service_1" "service_2" "service_3")
# Start function (required)
# This function should run as a daemon(does not exit)
start_fn() {
echo "Starting my_service..."
# Add your service start logic here
while true; do
echo "my_service is running..."
sleep 10
done
}
# Health check function (optional)
health_check() {
# Add your health check logic here
if curl -s http://localhost:8080/health > /dev/null; then
return 0
else
return 1
fi
}
```
## Contributing
Contributions are welcome! Please read the [Contributing Guidelines](./CONTRIBUTING.md) for details.
## License
Codjixd is licensed under the MIT License. See [LICENSE](./LICENSE) for more details.