Redis sessions, cache & queues
- 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,
])
];
Braden since am using a shared hosting.
I would be surprised if a shared hosting provider would offer redis. Unless they are able to separate its data between the customers/sites that run on one machine. Most likely they cannot, so if they do offer redis it might imply that they share sensitive data between customers/sites and as such that would be a red flag.
- Edited
matteocontrini very true because i had uninstalled Cloudflare long ago , so i got confused but still purge everything.
Inside
storage/logs there were no errors reported, i could have quote it.
use Flarum\Extend;
return [
new Blomstra\Redis\Extend\Redis([
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 1,
])
];
its added in extend.php but not found
and immediately after adding this code, with or without the extension installed, it brings the http 500 error
[deleted]
Braden if your host does not support redis (which I expect they won't), then this extension has no value, and you should remove it. This would also clear the HTTP 500 error.
luceos hello I like this extension but I don't want to install redis as per security reasons also I don't need cache as my speed is already good, but I still need queues so is their any alternative that works without redis. Also a suggestion that if the queues feature will be included built in in the core it will be more better as it's a must have feature.
- Edited
Hari If it is possible to set up a cron on your hosting that allows you to run tasks without a timeout. Then you can use the method I mentioned earlier: rafaucau
This script checks if the queue process is running, if not, it starts it. This way, when the process crashes, cron will restart it.
I use it on my forum because I don't have the possibility to manage processes there.
I think that if you have such a possibility on your hosting, it is better to use Redis queue than the database queue because of better performance.
- Edited
rafaucau you have replied to me earlier but at that moment i thought i don't need redies queue.. currently, i am using an extension it badly needs a queue so now re-visiting . thanks for mentioning it again, that really helps my situation. i will keep you posted
Ffuser1 you need to install Redis first, once go through readme. in my case, i have enabled it at cloudways dashboard