Restarting the mosquito broker

大憨熊 提交于 2019-12-12 07:59:12

问题


I have installed mosquito broker on my mac using brew install mosquitto.

Normally I don't give any commands to start the mosquitto server. It is started automatically when I switch on my mac.

I have verified that it is running by using the command ps -ef | grep mosquitto, which gives the following output

501   209   153   0  2:20PM ??       0:06.93/usr/local/opt/mosquitto/sbin/mosquitto -c /usr/local/etc/mosquitto/mosquitto.conf
501  2559  1007   0 10:36AM ttys001    0:00.00 grep mosquitto    
501   865   815   0  2:32PM ttys003    0:00.86 mosquitto_sub -h 127.0.0.1 -t esb.test2

Then I stopped the server by killing the mosquitto process using kill -9 above-pid.

Now I would like to know how can I restart the server again from command line, but without restarting my mac.


回答1:


If you've installed mosquitto from homebrew, you can use launchctl to control the service, e.g.

$ launchctl load /usr/local/Cellar/mosquitto/1.4.2/homebrew.mxcl.mosquitto.plist

$ launchctl unload /usr/local/Cellar/mosquitto/1.4.2/homebrew.mxcl.mosquitto.plist

$ launchctl start homebrew.mxcl.mosquitto
$ launchctl stop homebrew.mxcl.mosquitto



回答2:


You could kill the mosquitto process using the steps detailed in the answer here, then restart it in the same way you did originally.

To summarise the answer

killall mosquitto

Should do the job to stop the existing process.



来源:https://stackoverflow.com/questions/31045974/restarting-the-mosquito-broker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!