通过自制软件安装了memcached,如何启动和停止服务器?


85

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

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

  2. 是否有任何与memcached进行交互的命令行工具?

  3. 家酿有办法去除包裹吗?


可能与serverfault.com有关
Simon B.

Answers:


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

    brew info memcached
    
  2. 通过telnet: telnet localhost 11211

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

  3. brew remove memcached


6
“警告:不支持brew服务,将很快将其删除。您应该改用launchctl。” 请参阅clee的答案
Tieme,2014年

我已经将homebrew-services提取到其自己的存储库中,现在它已从主要的homebrew存储库中删除了 github.com/gapple/homebrew-services
gapple 2015年

请更新答案,所以现在开始以警告“过时的“酿酒服务”
Simon B.

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命令,如果您决定不希望使用该软件包,它将删除该软件包。


谢谢,我注意到它输出了更新安装的说明,但是当我很久以前安装它时,就不记得它是否使用memcached了。
Blankman

1
当然可以,但是您如何停止服务?
nessur 2012年

5
launchctl unload -w ~/Library/LaunchAgents/com.danga.memcached.plist当然。:)
clee

4
在某些时候文件名更改为 ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
drewish

1
感谢您更新答案!
2013年

41

另外,如果您忘记了说明,则可以运行“浏览信息”。

→ 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

将plist文件复制到我的〜/ Library / LaunchAgents /文件夹似乎并没有使它在启动时自动启动。:-(
Ryan

21

要重新启动:如果您的memcached启动为launchd并且您的plist文件包含

  <key>KeepAlive</key>
  <true/>

然后,您可以终止该进程,它将自动重启。

ps ux | grep memcached
pkill -f memcached
ps ux | grep memcached

要停止从自动重启启动:

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist

要将memcached添加到再次启动:

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist

卸载自制软件安装的东西:

brew uninstall memcached

15

您还可以创建别名

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

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

制止

$ lunchy stop memcached

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
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.