我已经通过自制软件安装了 memcached。
如何启动/停止服务器?
任何与 memcached 交互的命令行工具?
自制软件有删除包的方法吗?
当您安装它时,它会放置一个名为的homebrew.mxcl.memcached.plist
文件/usr/local/Cellar/memcached/$version/
;您将该文件复制到~/Library/LaunchAgents
其中,然后告诉 launchd 以launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
.
如果您在命令期间仔细观察控制台brew install
,它应该说明了执行这些确切步骤的内容。如果您运行brew info
它将重新打印此信息,例如brew info memcached
.
您可能应该阅读https://docs.brew.sh/Manpage - 它有更多有用的文档,包括brew remove
如果您决定不想要它,它将删除包的命令。
Brew曾经有一个命令 brew services ( https://thoughtbot.com/blog/starting-and-stopping-background-services-with-homebrew ),现在已弃用。相反,要获得始终正确的建议,请运行以下命令:
brew info memcached
通过远程登录:telnet localhost 11211
brew remove memcached
此外,如果您忘记了说明,您可以运行“brew info”。
→ brew info memcached
memcached 1.4.7
http://memcached.org/
Depends on: libevent
/usr/local/Cellar/memcached/1.4.6 (8 files, 156K)
You can enable memcached to automatically load on login with:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/memcached/1.4.7/com.danga.memcached.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/com.danga.memcached.plist
Or start it manually:
/usr/local/bin/memcached
Add "-d" to start it as a daemon.
http://github.com/mxcl/homebrew/commits/master/Library/Formula/memcached.rb
重新启动:如果您的 memcached 使用 launchd 启动,并且您的 plist 文件有
<key>KeepAlive</key>
<true/>
然后你可以杀死这个进程,它会自动重启。
ps ux | grep memcached
pkill -f memcached
ps ux | grep memcached
要停止 launchd 自动重启:
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
再次将 memcached 添加到 launchd:
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
卸载自制软件安装的东西:
brew uninstall memcached
您还可以创建别名
alias memcached-start="launchctl load ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist"
alias memcached-stop="launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist"
alias memcached-restart="launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist;launchctl load ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist"
之后你就不能轻松启动/停止/重新启动 memcached
memcached-start
memcached-stop
memcached-restart
您还可以使用Lunchy设置开始/停止。午餐是一个写在上面的包装launchctl
。我已经写了一篇关于这个的详细帖子。
$ gem install lunchy
$ mkdir ~/Library/LaunchAgents
$ cp /usr/local/Cellar/memcached/$version/homebrew.mxcl.memcached.plist ~/Library/LaunchAgents/
启动 memcached
$ lunchy start memcached
停止 memcached
$ lunchy stop memcached
您可以启用 Memcached 在登录时自动加载。
第一行创建了一个符号链接(符号链接),从 Homebrew 安装它的位置到 LaunchAgents 文件夹。
ln -sfv /usr/local/Cellar/memcached/1.4.17/homebrew.mxcl.memcached.plist ~/Library/LaunchAgents/
然后现在启动它:
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist