@@ -30,8 +30,8 @@ use Gt\Daemon\Pool;
3030
3131// Create three long-running processes:
3232$pingProcess = new Process("ping google.com");
33- $infiniteProcess = new Process("while true; do echo 'background...'; sleep 1 ; done");
34- $dateProcess = new Process("watch date -d now");
33+ $infiniteProcess = new Process("while true; do echo 'background...'; sleep 3 ; done");
34+ $dateProcess = new Process("while true; do echo $( date -d now); sleep 2; done ");
3535
3636// Add all three processes to a pool:
3737$pool = new Pool();
@@ -54,22 +54,17 @@ while($pool->numRunning() > 0);
5454Outputs something similar to:
5555
5656```
57- [Ping] PING google.com (172.217.169.14 ) 56(84) bytes of data.
58- [Ping] 64 bytes from lhr25s26 -in-f14.1e100.net (172.217.169.14 ): icmp_seq=1 ttl=54 time=27.2 ms
57+ [Ping] PING google.com (172.217.169.78 ) 56(84) bytes of data.
58+ [Ping] 64 bytes from lhr48s09 -in-f14.1e100.net (172.217.169.78 ): icmp_seq=1 ttl=52 time=8.78 ms
5959[Loop] background...
60- [Date] Fri 5 Apr 14:34:12 BST 2019
61- [Ping] 64 bytes from lhr25s26-in-f14.1e100.net (172.217.169.14): icmp_seq=2 ttl=54 time=17.7 ms
62- [Loop] background...
63- [Date] Fri 5 Apr 14:34:13 BST 2019
64- [Ping] 64 bytes from lhr25s26-in-f14.1e100.net (172.217.169.14): icmp_seq=3 ttl=54 time=14.4 ms
65- [Loop] background...
66- [Date] Fri 5 Apr 14:34:14 BST 2019
67- [Ping] 64 bytes from lhr25s26-in-f14.1e100.net (172.217.169.14): icmp_seq=4 ttl=54 time=24.9 ms
68- [Loop] background...
69- [Ping] 64 bytes from lhr25s26-in-f14.1e100.net (172.217.169.14): icmp_seq=5 ttl=54 time=13.9 ms
70- [Loop] background...
71- [Ping] 64 bytes from lhr25s26-in-f14.1e100.net (172.217.169.14): icmp_seq=6 ttl=54 time=15.8 ms
60+ [Date] Mon 19 Aug 09:58:54 BST 2019
61+ [Ping] 64 bytes from lhr48s09-in-f14.1e100.net (172.217.169.78): icmp_seq=2 ttl=52 time=8.75 ms
62+ [Ping] 64 bytes from lhr48s09-in-f14.1e100.net (172.217.169.78): icmp_seq=3 ttl=52 time=8.75 ms
63+ [Date] Mon 19 Aug 09:58:56 BST 2019
64+ [Ping] 64 bytes from lhr48s09-in-f14.1e100.net (172.217.169.78): icmp_seq=4 ttl=52 time=8.75 ms
7265[Loop] background...
66+ [Ping] 64 bytes from lhr48s09-in-f14.1e100.net (172.217.169.78): icmp_seq=5 ttl=52 time=8.80 ms
67+ [Date] Mon 19 Aug 09:58:58 BST 2019
7368```
7469
7570Notice how the date process is only set to loop three times, and after it is complete the other two infinite processes continue to run.
0 commit comments