Basically, I'm building an IoT oriented app. I created a couple binary files that turns on or off the pins of a Raspberry Pi. I have used PHP (running on the Raspberry Pi) to run those programs by executing a bash command in the past, which worked perfectly, like so:
exec('sudo /home/pi/Projects/calelec/rpi/on');
But what I need to do now, is to constantly read (long poll) an API service that will tell my Raspberry pi any instruction, and then execute something like the command above.
I know a cronjob will be ideal for this task (so I don't need to use the PHP part), but I need this to have a latency of .3 seconds.
I have read before that a daemon could work, but on that I know almost nothing. So I just need to be pointed to the right/better direction.