Recommend this page to a friend! |
![]() |
Info | Documentation | ![]() |
![]() |
![]() |
Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not enough user ratings | Total: 217 | All time: 8,299 This week: 97![]() |
Version | License | PHP version | Categories | |||
systemd-notify 1.0.1 | GNU General Publi... | 7.1 | Unix, Systems administration, PHP 7 |
Description | Author | |||
This package allows PHP applications to interact with the Systemd Notification daemon. Innovation Award
|
|
After downloading the example to the /opt/systemd-notify/examples/lookupd
directory, cd to the directory and execute:
composer install
Edit the lookupd.service file and adjust the User
, and Group
entries according to your needs, then execute:
sudo install lookupd.service
Starting the daemon is now as easy as just asking systemd: sudo systemctl start lookupd
and if the service started correctly, no further output is produced.
We can now query the status of our service by asking systemd:
[Andy@Awesome lookupd]$ sudo systemctl status lookupd
? lookupd.service - Example service to lookup hostnames
Loaded: loaded (/etc/systemd/system/lookupd.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2017-10-29 15:00:01 GMT; 5s ago
Main PID: 32033 (php)
Status: "Listening on 127.0.0.1:7777; Served 0 client(s)"
Tasks: 1 (limit: 4915)
CGroup: /system.slice/lookupd.service
??32033 /usr/bin/php /opt/systemd-notify/examples/lookupd/lookupd-start.php
This output tells us several things; it shows that the service is running properly and sending heartbeat (watchdog) events, and a status message.
A script has also been provided to test the daemon, let's run that a couple of times:
[Andy@Awesome lookupd]$ for counter in {1..10}; do php test-lookup.php; done
localhost.localdomain
localhost.localdomain
localhost.localdomain
localhost.localdomain
localhost.localdomain
localhost.localdomain
localhost.localdomain
localhost.localdomain
localhost.localdomain
localhost.localdomain
Now check the status again
[Andy@Awesome lookupd]$ sudo systemctl status lookupd
? lookupd.service - Example service to lookup hostnames
Loaded: loaded (/etc/systemd/system/lookupd.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2017-10-29 15:09:05 GMT; 9min ago
Main PID: 32033 (php)
Status: "Listening on 127.0.0.1:7777; Served 10 client(s)"
Tasks: 1 (limit: 4915)
CGroup: /system.slice/lookupd.service
??32033 /usr/bin/php /opt/systemd-notify/examples/lookupd/lookupd-start.php
Of course this is a contrived example but it clearly demonstrates how this package can be used in your own services.
This package allows scripts launched by systemd to send information and heartbeats (watchdog events) to the systemd notification system.
You have a script that is started as a service by systemd, and you want systemd to restart the service when it develops an error, or
You have a long running script and want to provide a status description viewable
by the systemctl status myservice
command.
Three classes are provided to interact with the notification service:
See the examples folder
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Doc. | Documentation |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
![]() |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.