Homebrew:如何检查自制软件服务是否打开
Homebrew: How to check if a homebrew service is switched on or not
我正在使用 elasticsearch
实例作为 nosql 数据库。这是在 mac os.
上与 brew
一起安装的
我就是这样开始的elasticsearch
。
brew services start elasticsearch
我想知道是否有 brew 命令(或其他命令)可以让我知道 elasticsearch
实例是否打开。
最终我想 运行 一个 bash 脚本 执行以下操作:
If elasticsearch is off:
Turn on elastiscearch
Proceed
Else:
Proceed
brew services list
给出服务的状态。所以像 brew services list | grep elastiscearch | awk '{ print }'
应该 return 弹性搜索服务的状态,无论是 started 还是 stopped
就运行:
brew services
示例输出
Name Status User Plist
grafana started mark /Users/mark/Library/LaunchAgents/homebrew.mxcl.grafana.plist
influxdb started mark /Users/mark/Library/LaunchAgents/homebrew.mxcl.influxdb.plist
mosquitto stopped
redis started mark /Users/mark/Library/LaunchAgents/homebrew.mxcl.redis.plist
unbound stopped
您还可以运行以下命令获取homebrew服务的进程ID(pid):
launchctl list | grep homebrew
460 0 homebrew.mxcl.influxdb
484 0 homebrew.mxcl.grafana
469 0 homebrew.mxcl.redis
我正在使用 elasticsearch
实例作为 nosql 数据库。这是在 mac os.
brew
一起安装的
我就是这样开始的elasticsearch
。
brew services start elasticsearch
我想知道是否有 brew 命令(或其他命令)可以让我知道 elasticsearch
实例是否打开。
最终我想 运行 一个 bash 脚本 执行以下操作:
If elasticsearch is off:
Turn on elastiscearch
Proceed
Else:
Proceed
brew services list
给出服务的状态。所以像 brew services list | grep elastiscearch | awk '{ print }'
应该 return 弹性搜索服务的状态,无论是 started 还是 stopped
就运行:
brew services
示例输出
Name Status User Plist
grafana started mark /Users/mark/Library/LaunchAgents/homebrew.mxcl.grafana.plist
influxdb started mark /Users/mark/Library/LaunchAgents/homebrew.mxcl.influxdb.plist
mosquitto stopped
redis started mark /Users/mark/Library/LaunchAgents/homebrew.mxcl.redis.plist
unbound stopped
您还可以运行以下命令获取homebrew服务的进程ID(pid):
launchctl list | grep homebrew
460 0 homebrew.mxcl.influxdb
484 0 homebrew.mxcl.grafana
469 0 homebrew.mxcl.redis