浏览 4190 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2009-06-03
一般就用下面两个参数
./server.sh init
./server.sh shutdown
shell脚本我不是很熟,看看各位有没有改进的地方
#!/bin/sh
##
## usage server.sh {init|start|stop|shutdown} ## First run,use init,create NODE ##
ERL=/usr/local/erlang/bin/erl
PA=/game/game_chat_server
export HEART_COMMAND="$PA/server.sh start"
case $1 in
init)
echo "Init Starting Server..." $ERL -boot game_server-1 -config sasl -sname chatserver01 \ -detached ;; start) echo "Starting Server..." $ERL -noshell -sname manage \ -eval 'server_manage:start("chatserver01@NBCTC-5-160","game_chat_server")' \ -s init stop ;; stop) echo "Stopping Server..." $ERL -noshell -sname manage \ -eval 'server_manage:stop("chatserver01@NBCTC-5-160","game_chat_server")' \ -s init stop ;; shutdown) echo "Shutdown Server..." $ERL -noshell -sname manage \ -eval 'server_manage:shutdown("chatserver01@NBCTC-5-160","game_chat_server")' \ -s init stop ;; *)
echo "Usage: $0 {init|start|stop|shutdown}" exit 1 esac exit 0 发现命令行 -s MODDULE Fun arg 这样的方式不好使,就改成 -eval的了
server_manage.erl 代码:
-module(server_manage). -export([start/2,stop/2,shutdown/2]). start(Node,Service) -> rpc:call(list_to_atom(Node),application,start,[list_to_atom(Service)]), io:format("~p:~p ok~n",[Node,Service]). stop(Node,Service) -> rpc:call(list_to_atom(Node),application,stop,[list_to_atom(Service)]), io:format("~p:~p ok~n",[Node,Service]). shutdown(Node,Service) -> rpc:call(list_to_atom(Node),application,stop,[list_to_atom(Service)]), rpc:call(list_to_atom(Node),init,stop,[]), io:format("~p:~p ok~n",[Node,Service]). 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2009-06-05
随便抄个 ejabberd或者 rabbitmq的就好了
|
|
返回顶楼 | |