
我使用brew 為我的node.js 應用程式安裝redis(鍵/值儲存資料庫伺服器)。
brew install redis
然而,它似乎消失了並且非常不穩定。因為我使用 Redis 作為會話存儲,所以當發生這種情況時,我需要能夠在我的 Mac 上快速重新啟動它。
如何重新啟動用brew安裝的redis?
答案1
更新
由於沒有人願意維護,brew 服務已過期。檢查如下: https://github.com/Homebrew/homebrew/issues/28657
檢查launchctl
功能代替。
或者lunchy
所以而不是:
launchctl load ~/Library/LaunchAgents/io.redis.redis-server.plist
你可以這樣做:
lunchy start redis
和:
lunchy ls
參考:https://github.com/eddiezane/lunchy
它曾經可以使用如下:
brew services restart redis
應該是你想要的重啟指令。你也可以運行
brew services list
這將為您提供釀造服務的清單。
答案2
自 2015 年 12 月 7 日起您可以使用brew services
.
您需要brew tap homebrew/services
然後以下內容將按預期工作:
安裝 brew install redis
開始 brew services start redis
停止 brew services stop redis
重新開始 brew services restart redis
答案3
Brew 不再支援該services
命令。
建議的方式是使用os x的launchctl
指令。
首先,您需要將 redis 設定為由 launchctl 管理的服務:
$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
然後你可以使用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
答案4
對於自製程序 1.5.14
redis-server