Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/win32service/win32servicebundle
The bundle for use Service-Library and Win32Service PHP ext into a Symfony Project.
https://github.com/win32service/win32servicebundle
php service-worker symfony symfony-bundle symfony4 win32 win32service windows
Last synced: 3 months ago
JSON representation
The bundle for use Service-Library and Win32Service PHP ext into a Symfony Project.
- Host: GitHub
- URL: https://github.com/win32service/win32servicebundle
- Owner: win32service
- License: mit
- Created: 2019-02-19T13:49:10.000Z (almost 6 years ago)
- Default Branch: 2.x
- Last Pushed: 2024-10-23T13:25:07.000Z (4 months ago)
- Last Synced: 2024-11-09T09:05:07.151Z (3 months ago)
- Topics: php, service-worker, symfony, symfony-bundle, symfony4, win32, win32service, windows
- Language: PHP
- Homepage: https://win32service.mactronique.fr/?mtm_campaign=home&mtm_source=github&mtm_medium=social&mtm_content=repo_win32servicebundle
- Size: 105 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Win32ServiceBundle
The bundle for use Service-Library and Win32Service PHP ext into a Symfony Project.# Install
```shell
composer require win32service/win32servicebundle
```# Configure
Add file `config/win32service.yaml` with this content:
```yaml
win32_service:
windows_local_encoding: ISO-8859-15 # The windows local encoding for convert the string UTF-8 from configuration to the local encoding.
logging_extra: # This configuration enable a processor for Monolog
enable: false # Enable a processor for add the thread number into the extra fields
channels: # The list of channels whom the processor add the thread number. If empty, the thread number is added for all channels.
- ref1
services:
# Prototype
-
service_id: "" # The service id. If `thread_count` > 1, you can use `%d` to define the place of the thread number
machine: "" # the machine name for this service.
displayed_name: "" # The friendly name of the service. If `thread_count` > 1, you can use `%d` to define the place of the thread number
script_path: ~ # the script name. If not defined, the integrated execute command is used.
script_params: "" # the arguments for the script. if `thread_count` > 1, you can use `%d` to define the place of the thread number
run_max: 1000 # number of loop before exit
thread_count: 1 # the number of this service need to register. Use `%d` into `service_id`, `displayed_name` and `script_params` for contains the service number.
description: "" # the service description
delayed_start: false # If true the starting for the service is delayed
exit: # Settings for the exit mode
graceful: true # if false, the exit fire the recovery action
code: 0 # If graceful is true, this value must not be 0
user: # The User set on the service
account: ~ # the account name
password: ~ # the password
recovery:
enable: false # The recovery action is disabled
delay: 60000 # The delay before run action (in millisecond)
action1: 0 # The action for the first fail
action2: 0 # The action for the second fail
action3: 0 # The action for the next fail
reboot_msg: "" # The message send to log if action is reboot the server
command: "" # The command to be execute if the action is 'run command'
reset_period: 86400 # The period before reset the fail count (in minutes)
dependencies: # The list of service depends
- Netman # An example of dependency.
messenger: # This configuration allow to set on Windows service the Symfony Messenger Consumer.
# Prototype
-
user: # The User set on the service
account: ~ # the account name
password: ~ # the password
receivers: [] # Symfony Messenger transport consumed by the service
machine: '' # the machine name for this service.
displayed_name: ~ # Required, The friendly name of the service. If `thread_count` > 1, you can use `%d` to define the place of the thread number
description: '' # the service description
thread_count: 1 # the number of this service need to register. Use `%d` into `service_id`, `displayed_name` and `script_params` for contains the service number.
delayed_start: false # If true the starting for the service is delayed
limit: 0 # Reboot service after processed X messages
failure-limit: 0 # Reboot service after X messages failure
time-limit: 0 # Reboot service after X seconds
```# Define the runner
For each service, add a sub-class of `Win32Service\Model\AbstractServiceRunner`.
The sub-class must be configured in service with the tag `win32service.runner` with an alias name corresponding to the `service_id`.## Exemple with one thread
Extension configuration:
```yaml
win32_service:
windows_local_encoding: ISO-8859-1
services:
-
service_id: "my_service"
displayed_name: "My beautiful service"
#[...]
```Sub-class:
```php
class MyRunner extends \Win32Service\Model\AbstractServiceRunner
{}
```Service configuration :
```yaml
services:
MyRunner:
tags:
- { name: win32service.runner, alias: 'my_service'}
```## Exemple with many thread
Extension configuration:
```yaml
win32_service:
windows_local_encoding: ISO-8859-1
services:
-
service_id: "my_service_%d"
displayed_name: "My beautiful service"
thread_count: 3
#[...]```
Sub-class:
```php
class MyRunner extends \Win32Service\Model\AbstractServiceRunner
{}```
Service configuration :
```yaml
services:
MyRunner:
tags:
- { name: win32service.runner, alias: 'my_service_%d'}
```# Manage the service
Open an administrator cmd window and go to your project.
## Register the service
For register all service, run this command:
```bash
php bin\console win32service:register
```For register only one service (without thread number) run:
```bash
php bin\console win32service:register --service-name=my_service
```
For register only one service (with thread number) run:```bash
php bin\console win32service:register --service-name=my_service_%d
```## Unregister the service
For unregister all service, run this command:
```bash
php bin\console win32service:unregister
```For unregister only one service (without thread number) run:
```bash
php bin\console win32service:unregister --service-name=my_service
```For unregister only one service (with thread number) run:
```bash
php bin\console win32service:unregister --service-name=my_service_%d
```## Sent action at your services
This command start all service (and all thread) defined in your project.
```bash
php bin\console win32service:action start
```For sent the action for one service and all thread:
```bash
php bin\console win32service:action start --service-name=my_service_%d
```For sent the action for one thread of one service (work same if the service has only one thread):
```bash
php bin\console win32service:action start --service-name=my_service_1
```