Closed scheung38 closed 9 years ago
You could do something as easy as-
import os
os.system("service redis_6379 start'")
but I think a fabfile would be the way to go. Fabric
Thanks Michael, if this is such an important task, not sure why most tutorials tell user to manually start in command line instead of doing this before every session?
Because it's a a process that should already running. Think of when you connect to postgres. You don't manually start the server for each session. Instead, you run it in the background. If I were you, I would simply set up a try/except block to test for the connection first, rather than writing a script to open the connection itself.
But it is to be deployed to AWS, so it may probably not be already running. I would have assumed that we need to launch it if it is not already running in the background?
import os
os.system("service redis_6379 restart")
returns
*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 104
>>> 'logfile /var/log/redis_6379.log'
Can't open the log file: Permission denied
* Running on http://127.0.0.1:5000/
* Restarting with reloader
/var/run/redis_6379.pid does not exist, process is not running
Starting Redis server...
*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 104
>>> 'logfile /var/log/redis_6379.log'
Can't open the log file: Permission denied
and
import os
os.system("sudo service redis_6379 restart")
returns
sudo: no tty present and no askpass program specified
* Running on http://127.0.0.1:5000/
* Restarting with reloader
sudo: no tty present and no askpass program specified
So is it straight forward to have redis (mongod or any other database servers) running on AWS or Heroku?
So AWS can easily deploy redis? if so how would you define that thanks
https://stackoverflow.com/questions/24374490/amazon-elasticcache-redis-public-access#answer-25913518 You can't access AWS Elastic Cache from outside aws, so you can't use that redis when developing locally.
Instead of launching redis from command line with :
how to do this within Python, thanks.