Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 24 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ jobs:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.version }}
release_name: ${{ github.event.inputs.version }}
draft: true
prerelease: false
steps:
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.version }}
name: ${{ github.event.inputs.version }}
draft: true
prerelease: false

build:
runs-on: ${{ matrix.runners.image }}
Expand Down Expand Up @@ -62,14 +62,12 @@ jobs:
target: aarch64-pc-windows-msvc
artifact: server-runner.exe

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable

- name: Install Linux aarch64 gcc
if: ${{ matrix.runners.name == 'linux-aarch64' }}
Expand All @@ -90,12 +88,10 @@ jobs:
- name: Compress artifact ${{ matrix.runners.name }}
run: tar -czf server-runner-${{ github.event.inputs.version }}-${{ matrix.runners.name }}.tar.gz -C ./target/${{ matrix.runners.target }}/release ${{ matrix.runners.artifact }}

- name: Upload Release Asset ${{ matrix.runners.name }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./server-runner-${{ github.event.inputs.version }}-${{ matrix.runners.name }}.tar.gz
asset_name: server-runner-${{ github.event.inputs.version }}-${{ matrix.runners.name }}.tar.gz
asset_content_type: application/gzip
- name: Upload Release Asset ${{ matrix.runners.name }}
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.version }}
files: ./server-runner-${{ github.event.inputs.version }}-${{ matrix.runners.name }}.tar.gz
40 changes: 40 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Lint

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
clippy:
runs-on: ubuntu-latest
name: Clippy

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy

- name: Run Clippy
run: cargo clippy -- -D warnings

rustfmt:
runs-on: ubuntu-latest
name: Format

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- name: Check Formatting
run: cargo fmt -- --check
14 changes: 6 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable

- name: Install simple http server
run: cargo install simple-http-server
Expand Down
83 changes: 64 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,67 @@ and it's much easier to publish than to many other package managers.
cargo install server-runner
~~~

## Configuration File

Example

~~~ yaml
servers:
- name: "My web server"
url: "http://localhost:8080"
command: "node webserver.js"
command: "node cypress"
~~~

~~~ sh
server-runner -c config.yaml
~~~

Default name of the config file is `servers.yaml` in your current working directory.

Server Runner will attempt to check a server's status up to ten times with one second between each attempt. If a server is not responding with HTTP 200 after that, Server Runner will shutdown all servers and exit.
## Usage

~~~ sh
server-runner [OPTIONS]
~~~

### Options

- `-c, --config <FILE>` - Path to configuration file (default: `servers.yaml`)
- `-v, --verbose` - Enable verbose logging
- `-a, --attempts <NUMBER>` - Maximum number of connection attempts per server (default: 10)
- `-h, --help` - Print help information
- `-V, --version` - Print version information

### Example

~~~ sh
server-runner -c config.yaml -v -a 15
~~~

## Configuration File

The configuration file is written in YAML format and defines the servers to start and the command to run when all servers are ready.

### Example Configuration

~~~ yaml
servers:
- name: "My web server"
url: "http://localhost:8080"
command: "node webserver.js"
timeout: 5 # Optional: HTTP request timeout in seconds (default: 5)

- name: "API server"
url: "http://localhost:3000/health"
command: "python api_server.py"
timeout: 10

command: "npm test"
~~~

### Configuration Fields

**servers** (required): List of servers to start and monitor

Each server requires:
- `name`: Display name for the server
- `url`: HTTP endpoint to check for availability (must return HTTP 200 when ready)
- `command`: Shell command to start the server
- `timeout`: (optional) HTTP request timeout in seconds (default: 5)

**command** (required): Command to execute when all servers are ready

## How It Works

Server Runner will:

1. Start all configured servers simultaneously
2. Poll each server's URL every second until it returns HTTP 200
3. Retry up to the maximum number of attempts (default: 10, configurable with `-a`)
4. Execute the specified command once all servers are ready
5. Shut down all servers when the command completes or if any error occurs

If any server fails to respond with HTTP 200 after the maximum attempts, Server Runner will shut down all servers and exit with an error.
Loading