This is a sample project developed by lumen framework to schedule web hooks through http apis.
This application has three different roles:
- Api
- Worker
- Scheduler
Api serves an http api in specified port. you can see full documentation of available api's in Swagger file.
You can simply setup an api server in port 8000 through following command:
php -S localhost:8000 -t public
This application uses queue to run web hooks, so we need to set up a queue tu process web hook jobs:
php artisan queue:listen --queue=hooks
The last part is scheduler, you can schedule a hook by performing a POST request to http://localhost:8000/v1/hooks
api, internally this stores a hook object with it's cron pattern in database, and after that we use Laravel's task scheduler
to schedule hooks.
For this we need one cron job in our system to be ran in every minute:
* * * * * su -c '/usr/local/bin/php /path/to/project/artisan schedule:run >> /var/log/schedule.log 2>&1'
Simply you can use Docker to run all of the things, for this you should do only following command:
make up