1
我想在我的部署過程中使用Beanstalkd。這個想法與IGN使用的想法類似(https://github.com/ign/brood)。在任何時候,我都可能想要觸發兩個客戶端下載最新的代碼並重新啓動Apache。是否有可能讓多個工作人員(每個客戶端上一個工作人員)處理相同的隊列?作爲解決方法,我可以爲每個客戶端創建一個隊列。Beanstalkd - 訪問同一隊列的多個工作人員
我想在我的部署過程中使用Beanstalkd。這個想法與IGN使用的想法類似(https://github.com/ign/brood)。在任何時候,我都可能想要觸發兩個客戶端下載最新的代碼並重新啓動Apache。是否有可能讓多個工作人員(每個客戶端上一個工作人員)處理相同的隊列?作爲解決方法,我可以爲每個客戶端創建一個隊列。Beanstalkd - 訪問同一隊列的多個工作人員
每個客戶端的特定隊列,用於該客戶端的命令。讓他們都聽自己的隊列,並根據需要發送簡單的「重新啓動」消息給多少個客戶端。
我會有一個bash腳本啓動作業,並保持它運行執行實際重新啓動。你的腳本只需要
exit(90);
返回值由猛砸拿起劇本腳本,並執行操作。
#!/bin/bash
# runBeanstalkd-worker.sh
# a shell script that keeps looping until an exit code is given
# if it does an exit(0), restart after a second - or if it's a declared error
# if we've restarted in a planned fashion, we don't bother with any pause
# and for one particular code, exit the script entirely.
# The numbers 97, 98, 99 must match what is returned from the PHP script
nice php -q -f ./cli-beanstalk-worker.php -- [email protected]
ERR=$?
## Possibilities
# 90 - restart apache
# 97 - planned pause/restart
# 98 - planned restart
# 99 - planned stop, exit.
# 0 - unplanned restart (as returned by "exit;")
# - Anything else is also unplanned paused/restart
# 90 - restart apache
if [ $ERR -eq 90 ]
then
service apache restart
sleep 5;
exec $0 [email protected];
fi
if [ $ERR -eq 97 ]
then
# a planned pause, then restart
echo "97: PLANNED_PAUSE - wait 1";
sleep 1;
exec $0 [email protected];
fi
#### other actions, like planned-restart, or shutdown
# unplanned exit, pause, and restart
echo "unplanned restart: err:" $ERR;
echo "sleeping for 1 sec"
sleep 1
exec $0 [email protected]