85

我已经通过自制软件安装了 memcached。

  1. 如何启动/停止服务器?

  2. 任何与 memcached 交互的命令行工具?

  3. 自制软件有删除包的方法吗?

4

7 回答 7

81

当您安装它时,它会放置一个名为的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如果您决定不想要它,它将删除包的命令。

于 2011-06-06T08:20:07.150 回答
43
  1. Brew曾经有一个命令 brew services ( https://thoughtbot.com/blog/starting-and-stopping-background-services-with-homebrew ),现在已弃用。相反,要获得始终正确的建议,请运行以下命令:

    brew info memcached
    
  2. 通过远程登录:telnet localhost 11211

    另请参阅有哪些有用的提示/工具可用于监控/调整 memcached 运行状况?

  3. brew remove memcached

于 2014-04-11T14:31:32.247 回答
41

此外,如果您忘记了说明,您可以运行“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
于 2011-09-29T17:57:09.760 回答
22

重新启动:如果您的 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
于 2012-07-05T18:39:45.740 回答
16

您还可以创建别名

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
于 2014-01-27T08:14:58.370 回答
6

您还可以使用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
于 2014-03-13T22:53:27.360 回答
4

您可以启用 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
于 2014-05-30T15:10:41.633 回答