Service plugin

  • Since RR v2.5.0
  • Client API link

Main capabilities

  1. Execute PHP code, binaries, bash/powershell scripts.
  2. Restart after specified amount of time.
  3. Control execute time for the particular command.
  4. Provide statistic to the Informer plugin about %CPU, PID and used RSS memory.


version: "2.7"

    command: "php tests/plugins/service/test_files/loop.php"
    process_num: 10
    exec_timeout: 0s
    remain_after_exit: true
    service_name_in_log: false
       - foo: "BAR"
    restart_sec: 1

    command: "tests/plugins/service/test_files/test_binary"
    process_num: 1
    remain_after_exit: true
    service_name_in_log: false
    restart_sec: 1s
       - foo: "BAR"
    exec_timeout: 10s


  1. Service plugin supports any number of nested commands.

  2. command - command to execute. There are no limitations on commands here. Here could be binary, PHP file, script, etc.

  3. process_num - default: 1, number of processes for the command to fire.

  4. exec_timeout - default: 0s (unlimited), maximum allowed time to run for the process. Can be in the form of: 1h, 1m or 1s (h,m,s).

  5. remain_after_exit - default: false. Remain process after exit. For example, if you need to restart process every 10 seconds exec_timeout should be 10s, and remain_after_exit should be set to true. NOTE: if you kill the process from outside and if remain_after_exit will be true, the process will be restarted.

  6. restart_sec - default: 30 seconds. Delay between process stop and restart.

  7. service_name_in_log - default: false, show the service name in the log in the form %plugin%.%service_name%.

  8. env - environment variables to pass to the underlying process from the config.

RPC Interface

Since RR v2.9 you have an ability to manage services via RPC interface.

All communication between PHP and GO made by the RPC calls with protobuf payloads. You can find versioned proto-payloads here: Proto.

  • Create(in *serviceV1.Create, out *serviceV1.Response) error - Create a new service.
  • Restart(in *serviceV1.Service, out *serviceV1.Response) error - Restart an exist service.
  • Terminate(in *serviceV1.Service, out *serviceV1.Response) error - Terminate (Kill) an exist service.
  • Status(in *serviceV1.Service, out *serviceV1.Status) error - Get status for an exist service.
  • List(_ *serviceV1.Service, out *serviceV1.List) error - Get list of available services.

Integration with PHP

If you need to manage RR services in your PHP project you can use composer package spiral/roadrunner-services for that.

Edit this page