https://github.com/roadrunner-php/services
🔌 RoadRunner Services SDK
https://github.com/roadrunner-php/services
Last synced: about 2 months ago
JSON representation
🔌 RoadRunner Services SDK
- Host: GitHub
- URL: https://github.com/roadrunner-php/services
- Owner: roadrunner-php
- License: mit
- Created: 2022-04-05T09:04:12.000Z (almost 4 years ago)
- Default Branch: 2.x
- Last Pushed: 2025-06-23T08:24:09.000Z (9 months ago)
- Last Synced: 2025-08-26T17:42:25.687Z (7 months ago)
- Language: PHP
- Homepage: https://roadrunner.dev
- Size: 48.8 KB
- Stars: 8
- Watchers: 5
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# Roadrunner services manager
[](https://packagist.org/packages/spiral/roadrunner-services)
[](https://packagist.org/packages/spiral/roadrunner-services)
[](https://github.com/spiral/roadrunner-services/actions)
[](https://github.com/spiral/roadrunner-services/actions)
[](https://packagist.org/packages/spiral/roadrunner-services)
This package will help you to manage [Roadrunner services](https://docs.roadrunner.dev/plugins/service)
## Requirements
Make sure that your server is configured with following PHP version and extensions:
- PHP 8.1+
## Installation
You can install the package via composer:
```bash
composer require spiral/roadrunner-services
```
## Usage
Such a configuration would be quite feasible to run:
```yaml
rpc:
listen: tcp://127.0.0.1:6001
service: {}
```
Then you need to create an instance of `Spiral\RoadRunner\Services\Manager`
```php
use Spiral\RoadRunner\Services\Manager;
use Spiral\Goridge\RPC\RPC;
$rpc = RPC::create('tcp://127.0.0.1:6001'));
$manager = new Manager($rpc);
```
### Create a new service
```php
use Spiral\RoadRunner\Services\Exception\ServiceException;
try {
$result = $manager->create(
name: 'listen-jobs',
command: 'php app.php queue:listen',
processNum: 3,
execTimeout: 0,
remainAfterExit: false,
env: ['APP_ENV' => 'production'],
restartSec: 30
);
if (!$result) {
throw new ServiceException('Service creation failed.');
}
} catch (ServiceException $e) {
// handle exception
}
```
### Check service status
```php
use Spiral\RoadRunner\Services\Exception\ServiceException;
try {
$status = $manager->statuses(name: 'listen-jobs');
// Will return an array with statuses of every run process
// [
// [
// 'cpu_percent' => 59.5,
// 'pid' => 33,
// 'memory_usage' => 200,
// 'command' => 'foo/bar',
// 'error' => null
// ],
// [
// 'cpu_percent' => 60.2,
// 'pid' => 34,
// 'memory_usage' => 189,
// 'command' => 'foo/bar'
// 'error' => [
// 'code' => 1,
// 'message' => 'Process exited with code 1'
// 'details' => [...] // array with details
// ]
// ],
// ]
} catch (ServiceException $e) {
// handle exception
}
```
### Restart service
```php
use Spiral\RoadRunner\Services\Exception\ServiceException;
try {
$result = $manager->restart(name: 'listen-jobs');
if (!$result) {
throw new ServiceException('Service restart failed.');
}
} catch (ServiceException $e) {
// handle exception
}
```
### Terminate service
```php
use Spiral\RoadRunner\Services\Exception\ServiceException;
try {
$result = $manager->terminate(name: 'listen-jobs');
if (!$result) {
throw new ServiceException('Service termination failed.');
}
} catch (ServiceException $e) {
// handle exception
}
```
### List of all services
```php
use Spiral\RoadRunner\Services\Exception\ServiceException;
try {
$services = $manager->list();
// Will return an array with services names
// ['listen-jobs', 'websocket-connection']
} catch (ServiceException $e) {
// handle exception
}
```