0

我正在尝试在全新的 Mac 上本地运行 django 项目。它一直工作到昨天,我不知道发生了什么,但突然间我开始收到 Redis 错误。

我可以加载不查询数据库的页面,但是一旦我尝试进行部分依赖于 Redis 的搜索,它就不起作用了。

有任何想法吗?这是回溯。

Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/Library/Python/2.7/site-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
    return self.application(environ, start_response)
  File "/Library/Python/2.7/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
    response = self.get_response(request)
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 179, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/Users/dlitwak/mozio/dotcloud/demo/search/views.py", line 391, in results
    cache.setDistanceAndDuration(distance, time, request.user.username)
  File "/Users/dlitwak/mozio/dotcloud/demo/cache.py", line 305, in setDistanceAndDuration
    self.cache.set(key, value, 1800)
  File "/Library/Python/2.7/site-packages/redis_cache/cache.py", line 218, in set
    result = self._set(key, pickle.dumps(value), int(timeout), client, _add_only)
  File "/Library/Python/2.7/site-packages/redis_cache/cache.py", line 199, in _set
    return client.setex(key, value, timeout)
  File "/Library/Python/2.7/site-packages/redis/client.py", line 1221, in setex
    return self.execute_command('SETEX', name, time, value)
  File "/Library/Python/2.7/site-packages/redis/client.py", line 338, in execute_command
    connection.send_command(*args)
  File "/Library/Python/2.7/site-packages/redis/connection.py", line 287, in send_command
    self.send_packed_command(self.pack_command(*args))
  File "/Library/Python/2.7/site-packages/redis/connection.py", line 269, in send_packed_command
    self.connect()
  File "/Library/Python/2.7/site-packages/redis/connection.py", line 217, in connect
    raise ConnectionError(self._error_message(e))
ConnectionError: Error 2 connecting to unix socket: 127.0.0.1. No such file or directory.

我们正在运行 MYSQL。我可以通过终端访问数据库,所以我认为这不是数据库访问问题。

4

3 回答 3

0

好的,所以我们终于让它工作了。

由于某种原因,Redis 不再自动启动,也没有在后台运行。

我在 Mac 上工作,以前我在 Ubuntu 上运行时它会自动执行此操作。解决方案是在单独的终端窗口中运行“redis-server”。

我们仍在试图弄清楚如何让它自动启动,或者为什么它首先停止,但是是的。

于 2012-10-08T20:43:41.367 回答
0

如果您使用的是 Mac,使用Homebrew包管理器可能是安装和管理 Redis 的最佳方式。简单地安装 Homebrew 后,brew install redis在命令行上。

安装后,您可以将其设置为在启动时自动运行:

ln -sfv /usr/local/opts/redis/*.plist ~/Library/LaunchAgents

然后现在运行它:

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

于 2014-03-17T20:06:27.053 回答
0

有时这是因为 Django 无法连接到数据库,而 redis 正在抛出错误。而且由于您可以在没有 db 的情况下加载页面,因此似乎就是这样。

于 2012-10-06T01:43:13.847 回答