Xperience.cloud - Gearman: Difference between revisions
Created page with "The xperience.cloud runs a parallel worker execution service using http://gearman.org Enviroment Stage and Live-Servers are using separate Gearman instances. Stage The Stage..." |
Tag: visualeditor |
||
| (6 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
The xperience.cloud runs a parallel worker execution service using http://gearman.org | The xperience.cloud runs a parallel worker execution service using http://gearman.org | ||
Enviroment | ===== Enviroment ===== | ||
Stage and Live-Servers are using separate Gearman instances. | Stage and Live-Servers are using separate Gearman instances. | ||
Stage | |||
====== Stage ====== | |||
The Stage Servers Gearman is configured as "GEARMAN_SERVER" in the .env file and is pointing to | The Stage Servers Gearman is configured as "GEARMAN_SERVER" in the .env file and is pointing to | ||
GEARMAN_SERVER = ip-172-31-34-64.eu-central-1.compute.internal | GEARMAN_SERVER = ip-172-31-34-64.eu-central-1.compute.internal | ||
what is the private DNS for the Stage-Server himself. | |||
Prod | |||
====== Prod ====== | |||
The Prod Servers Gearman is configured as "GEARMAN_SERVER" in the .env file and is pointing to | The Prod Servers Gearman is configured as "GEARMAN_SERVER" in the .env file and is pointing to | ||
GEARMAN_SERVER = ip-172-31-27-199.eu-central-1.compute.internal | GEARMAN_SERVER = ip-172-31-27-199.eu-central-1.compute.internal | ||
what is the service.xperience.cloud EC2 Instances private DNS. | |||
Worker | |||
===== Worker ===== | |||
Gearman Jobs are called "Worker". The workers are located in "/gearman/jobs/" and will be initialised by "gearman/worker.php". | Gearman Jobs are called "Worker". The workers are located in "/gearman/jobs/" and will be initialised by "gearman/worker.php". | ||
New Worker Code / Restarting the Workers | |||
====== New Worker Code / Restarting the Workers ====== | |||
To use new code, you have to restart the workers. You can restart the workers by just killing them using | To use new code, you have to restart the workers. You can restart the workers by just killing them using | ||
sudo pkill -f worker.php | sudo pkill -f worker.php | ||
on the corresponding gearman machine. | |||
Logging | |||
The Gearman Worker's php code should log into the syslog ("/var/log/syslog"). The Gearman Job Server itself is logging into his own log at "/var/log/gearman-job-server/gearmand.log". To watch your Gearman Jobs running or debug them, you can use | ====== Logging ====== | ||
The Gearman Worker's php code should log into the syslog ("/var/log/syslog"). The Gearman Job Server itself is logging into his own log at "/var/log/gearman-job-server/gearmand.log". To watch your Gearman Jobs running or debug them, you can use<syntaxhighlight lang="shell"> | |||
sudo tail -f /var/log/syslog /var/log/php7.3-fpm.log /var/log/gearman-job-server/gearmand.log | sudo tail -f /var/log/syslog /var/log/php7.3-fpm.log /var/log/gearman-job-server/gearmand.log | ||
Using | </syntaxhighlight> | ||
====== Using ====== | |||
You can use the Gearman worker in your code by adding a new Client | You can use the Gearman worker in your code by adding a new Client | ||
<syntaxhighlight lang="php" line="1"> | |||
$client = new GearmanClient(); | $client = new GearmanClient(); | ||
$client->addServer(getenv('GEARMAN_SERVER')); | $client->addServer(getenv('GEARMAN_SERVER')); | ||
</syntaxhighlight> | |||
and sending your payload to it | and sending your payload to it | ||
<syntaxhighlight lang="php" line="1"> | |||
$result = $client->doBackground('send_twilio_sms_or_voice', json_encode(array( | $result = $client->doBackground('send_twilio_sms_or_voice', json_encode(array( | ||
"meta" => array( | "meta" => array( | ||
| Line 35: | Line 45: | ||
) | ) | ||
))); | ))); | ||
</syntaxhighlight> | |||
'''Please mind, that Gearman workers do not give an execution result.''' | |||
Current Workers | ===== Current Workers ===== | ||
There are two workers for | There are two workers for | ||
Sending (RAW) Emails via Amazon AWS / SES (gearman/jobs/send_aws_ses.php) | |||
Sending SMS and doing Voicecalls via Twilio (gearman/jobs/send_twilio_sms_or_voice.php) | * Sending (RAW) Emails via Amazon AWS / SES (gearman/jobs/send_aws_ses.php) | ||
* Sending SMS and doing Voicecalls via Twilio (gearman/jobs/send_twilio_sms_or_voice.php) | |||
Latest revision as of 10:48, 8 February 2021
The xperience.cloud runs a parallel worker execution service using http://gearman.org
Enviroment
[edit]Stage and Live-Servers are using separate Gearman instances.
Stage
[edit]The Stage Servers Gearman is configured as "GEARMAN_SERVER" in the .env file and is pointing to
GEARMAN_SERVER = ip-172-31-34-64.eu-central-1.compute.internal
what is the private DNS for the Stage-Server himself.
Prod
[edit]The Prod Servers Gearman is configured as "GEARMAN_SERVER" in the .env file and is pointing to
GEARMAN_SERVER = ip-172-31-27-199.eu-central-1.compute.internal
what is the service.xperience.cloud EC2 Instances private DNS.
Worker
[edit]Gearman Jobs are called "Worker". The workers are located in "/gearman/jobs/" and will be initialised by "gearman/worker.php".
New Worker Code / Restarting the Workers
[edit]To use new code, you have to restart the workers. You can restart the workers by just killing them using
sudo pkill -f worker.php
on the corresponding gearman machine.
Logging
[edit]The Gearman Worker's php code should log into the syslog ("/var/log/syslog"). The Gearman Job Server itself is logging into his own log at "/var/log/gearman-job-server/gearmand.log". To watch your Gearman Jobs running or debug them, you can use<syntaxhighlight lang="shell"> sudo tail -f /var/log/syslog /var/log/php7.3-fpm.log /var/log/gearman-job-server/gearmand.log </syntaxhighlight>
Using
[edit]You can use the Gearman worker in your code by adding a new Client <syntaxhighlight lang="php" line="1"> $client = new GearmanClient(); $client->addServer(getenv('GEARMAN_SERVER')); </syntaxhighlight> and sending your payload to it <syntaxhighlight lang="php" line="1"> $result = $client->doBackground('send_twilio_sms_or_voice', json_encode(array(
"meta" => array(
'twilio_number_voice' => $phone_from_voice
),
"data" => array(
'phone_to' => $telephone,
'phone_type' => 'voice',
'phone_body' => $phone_body
)
))); </syntaxhighlight> Please mind, that Gearman workers do not give an execution result.
Current Workers
[edit]There are two workers for
- Sending (RAW) Emails via Amazon AWS / SES (gearman/jobs/send_aws_ses.php)
- Sending SMS and doing Voicecalls via Twilio (gearman/jobs/send_twilio_sms_or_voice.php)