diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-08-10 01:01:34 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-08-10 01:01:34 +0300 |
commit | 5c0fc1fc767b7b447d787d8123b23e99a35b8577 (patch) | |
tree | 020ec097774629268481a47c98e70a53519057bc /herculeswrapper/include.sh | |
parent | 5b99ec96cf46a9a3b6687a7fbf8ef1d379d99f83 (diff) | |
download | evol-tools-5c0fc1fc767b7b447d787d8123b23e99a35b8577.tar.gz evol-tools-5c0fc1fc767b7b447d787d8123b23e99a35b8577.tar.bz2 evol-tools-5c0fc1fc767b7b447d787d8123b23e99a35b8577.tar.xz evol-tools-5c0fc1fc767b7b447d787d8123b23e99a35b8577.zip |
add herculeswrapper.
For now this is basic wrapper.
Allow:
terminate all servers
restart all servers
restart char and map servers
restart map server
Diffstat (limited to 'herculeswrapper/include.sh')
-rw-r--r-- | herculeswrapper/include.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/herculeswrapper/include.sh b/herculeswrapper/include.sh new file mode 100644 index 0000000..fe0c276 --- /dev/null +++ b/herculeswrapper/include.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +function create_pipe { + trap "rm -f $PIPE" EXIT + if [[ ! -p $PIPE ]]; then + echo "Making pipe $PIPE" + rm -f $PIPE + mkfifo $PIPE + fi +} + +# $1 - text +function send_all_pipes { + echo $1 >$LOGIN_PIPE + echo $1 >$CHAR_PIPE +} + +# $1 - text +function send_char_pipe { + echo $1 >$CHAR_PIPE +} + +# $1 - server binary name +# $2 - sleep time +function server_logic { + create_pipe + $1 + + while true + do + if read line <$PIPE; then + echo pipe: $line + if [[ "$line" == 'exit' ]]; then + exit + fi + if [[ "$line" == 'restart' ]]; then + sleep $2 + $1 + fi + fi + done +} |