Redis sessions, cache & queues
luceos i have added this in extend.php file
return [
(new Blomstra\Redis\Extend\Redis([
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 1,
]))
->useDatabaseWith('cache', 1)
->useDatabaseWith('queue', 2)
->useDatabaseWith('session', 3)
];
if i run this command php flarum queue:work
i am getting this result
[2021-07-11 07:56:00][qByowZ3FOKSbh28b6wNoaYkztHZE9hBK] Processing: Flarum\Notification\Job\SendNotificationsJob
[2021-07-11 07:56:00][qByowZ3FOKSbh28b6wNoaYkztHZE9hBK] Processed: Flarum\Notification\Job\SendNotificationsJob
does this mean its working?
- Edited
luceos sorry, i am not getting this step
so i need to install supervisor its an extension from larvel (server level) and need to configure it right?
https://laravel.com/docs/6.x/queues#supervisor-configuration
Edit: i don't have access, cloudways limit certain commands. its a long process to explain them regarding this. i will wait for GB setup
Hari sessions and cache work perfectly fine without the queue. Make sure to use disable('queue')
in your extend.php
:
return [
(new Blomstra\Redis\Extend\Redis([
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 1,
]))
->useDatabaseWith('cache', 1)
->useDatabaseWith('session', 3)
->disable('queue')
];
- Edited
Hari i don't have access, cloudways limit certain commands. its a long process to explain them regarding this. i will wait for GB setup
If you don't have full access on the server because you have shared hosting, for example, then you can still use Redis Queue.
What I did was to set up a cron for such a script:
#set -x
queue=`ps -aux | grep "flarum queue:work" | grep -v grep`
if [[ -z $queue ]]; then
while true :
do
[[ -z $queue ]] && { php flarum queue:work; }
done
else
exit 0
fi
When a process fails for some reason, cron will start it again.
- Edited
edit : its working now - it happened due to cloudflare cache
edit2:
luceos This step is required to have the queue process jobs in the background, unattended. To get this done it needs to run as a daemon, continuously and be restarted on failure. If you don't take care of this step, pending jobs will pile up without being processed.
if i do not want queues i don't need deamon and need not to maintain anything right?
- Edited
sanwhere I didn't add this, I get the think, but how can I do that, can you give me an example or clue so I can dig it.
if you are a non-techqnical person ignore that step. (i have ignored) just go with below mentioned setup
return [
(new Blomstra\Redis\Extend\Redis([
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 1,
]))
->useDatabaseWith('cache', 1)
->useDatabaseWith('session', 3)
->disable('queue')
];
luceos To get this done it needs to run as a daemon, continuously and be restarted on failure. If you don't take care of this step, pending jobs will pile up without being processed.
- Edited
I tried to install it on flarum 15 using composer require blomstra/flarum-redis: ^ 0.2.4-beta
It installed successfully
Then i went inside public_html/vendor/blomstra/flarum-redis/extend.php
i updated it like this
return [
new Blomstra\Redis\Extend\Redis([
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 1,
])
];
I activated it in admin panel and
then i run php flarum queue:work which i got this response There are no commands defined in the "queue" namespace.
I Ignored, and tried to surf my site but then it had already broken showing the HTTP/Server message.
Inside storage/cache there were many folders populated
Maybe am missing something?
My flarum speed grade score is C. I want to make this one work and score A like @[deleted]
- Edited
install supervisor
with this command on your server:
sudo yum -y install supervisor
(Cent-OS)
than run it and enable it on restart:
sudo systemctl start supervisord
sudo systemctl enable supervisord
add this after the last line of supervisord.conf
file:
[program:any_name]
process_name=%(program_name)s_%(process_num)02d
command=php flarum queue:work sqs --sleep=3 --tries=3
directory=/path_to_flarum
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/path_to_flarum/worker.log
stopwaitsecs=3600
after that, run this command:
systemctl restart supervisord
than this to see if it is active:
systemctl status supervisord
you can check the log file at /var/log/supervisor/supervisord.log
and search for INFO success:
at the last line. if you see that, supervisor is running and it will run your command on restart.
Braden did you add the lines exiting file or you created a new file?
exiting file need to be like below:
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Flarum\Extend;
return [
new Blomstra\Redis\Extend\Redis([
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 1,
])
];