cho*_*ovy 75 reboot homebrew macos
我使用 brew 为我的 node.js 应用程序安装 redis(一个键/值存储数据库服务器)。
brew install redis
Run Code Online (Sandbox Code Playgroud)
然而,它似乎消失了,并且非常不稳定。因为我使用 redis 作为我的会话存储,所以当发生这种情况时,我需要能够在我的 mac 上快速重新启动它。
如何重新启动我用 brew 安装的 redis?
ken*_*ken 69
更新
brew 服务由于没有人想要维护它而过期。检查以下:https : //github.com/Homebrew/homebrew/issues/28657
launchctl改为检查功能。
或者 lunchy
所以而不是:
launchctl load ~/Library/LaunchAgents/io.redis.redis-server.plist
Run Code Online (Sandbox Code Playgroud)
你可以这样做:
lunchy start redis
Run Code Online (Sandbox Code Playgroud)
和:
lunchy ls
Run Code Online (Sandbox Code Playgroud)
参考资料:https : //github.com/eddiezane/lunchy
它曾经能够使用如下:
brew services restart redis
Run Code Online (Sandbox Code Playgroud)
应该是你想要的重启命令。你也可以运行
brew services list
Run Code Online (Sandbox Code Playgroud)
这将为您提供您的酿造服务列表。
mic*_*ino 42
截至 2015 年 12 月 7 日,您可以使用brew services.
您需要brew tap homebrew/services然后 thw 以下将按预期工作:
安装 brew install redis
开始 brew services start redis
停止 brew services stop redis
重新开始 brew services restart redis
更多信息在这里:https : //github.com/Homebrew/homebrew-services
oDD*_*ooL 24
Brew 不再支持该services命令。
推荐的方式是使用 os x 的launchctl命令。
首先,您需要将 redis 设置为由 launchctl 管理的服务:
$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
Run Code Online (Sandbox Code Playgroud)
然后你可以使用launchctl load/launchctl unload来启动/停止服务:
$ # start redis server
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
$
$ # stop redis server
$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Run Code Online (Sandbox Code Playgroud)
cho*_*ovy 19
我发现 brew package ( brew info redis) 中列出的所有这些选项都非常有问题。例如,如果 redis 不是以 root 启动,则会抛出一堆错误。我最终只是用 sudo 直接调用并删除了 launchctl 文件。
sudo redis-server /usr/local/etc/redis.conf
Run Code Online (Sandbox Code Playgroud)
我希望有一种方法可以轻松地从命令行重新启动 redis,但这似乎不可能。因此,我将守护进程模式设置为“否”并观察它记录到标准输出,然后我可以轻松地杀死它。