I have installed my mod on linux server and wanted a script to make sure it is running .This one checks every minute and if not it starts it.
I have 2 questions ...
1.Will linux read my nwnplayer.ini settings so I dont have to put in script?
2.Dont I have to make sure this line is in the script? export LD_LIBRARY_PATH=./miles:$LD_LIBRARY_PATH
Script::::::
#!/bin/bash
# NWN Server Process Monitor
#Get in the right directory
NWN_DIR=/home/georage/NWN
cd $NWN_DIR
# Command to run
RESTART="./nwserver -module mine2keep"
#path to pgrep command
PGREP="/usr/bin/pgrep"
# daemon name
HTTPD="nwserver"
# find pid
$PGREP ${HTTPD}
if [ $? -ne 0 ] # if not running
then
# restart
$RESTART
fi
this is where I got the script from ::::
http://nwn.bioware.c...&forum=56&sp=75
Linux boot script question?
Débuté par
Knight_Shield
, févr. 28 2011 01:37
#1
Posté 28 février 2011 - 01:37
#2
Posté 28 février 2011 - 11:50
I just tried it: Yes, your nwnplayer.ini will be loaded and the settings used. nwserver won't even start up correctly if nwn.ini and nwnplayer.ini are not present.
And no, the LD_LIBRARY_PATH settings are only necessary for nwmain (the nwn linux client), because they point to the miles shared objects that are needed for audio output.
HTH
Greetings
Skildron
And no, the LD_LIBRARY_PATH settings are only necessary for nwmain (the nwn linux client), because they point to the miles shared objects that are needed for audio output.
HTH
Greetings
Skildron
Modifié par Skildron, 28 février 2011 - 11:53 .
#3
Posté 28 février 2011 - 05:18
By the way, in the thread you got your script from, there are a lot of more sophisticated solutions. I especially like this one. See this thread on instructions how to use it.
Greetings
Skildron
Greetings
Skildron
#4
Posté 28 février 2011 - 09:54
Ahh thank you very much for your input .Your answers have added many missing peices to the puzzle for me. I am no scripter or linux person but with the help from this community and the content people haved created and shared ..I have my project on the run.Thanks again Skildron
#5
Posté 01 mars 2011 - 04:20
The script skil posted is a good one, as a note the default buffer size in most linux installs is only 8192 bytes, so the line
CATCH_OUTPUT="empty -r -t 30 -b 2048000 -i out.fifo"
you should probably change that value to 8192 unless you want to rebuild the kernel yourself. (though I see Skil linked to my post on it)
The only part I had issue with was the password removal, never could get the line:
WAIT_LOADED="empty -w -t $SECONDS_TO_WAIT -i out.fifo -o in.fifo $PASS_PHRASE" # FOR nwnstartup.sh
to work satisfactorily. Maybe Skil can provide insight, the script is infinitely more powerful and useful than the basic one you had.
CATCH_OUTPUT="empty -r -t 30 -b 2048000 -i out.fifo"
you should probably change that value to 8192 unless you want to rebuild the kernel yourself. (though I see Skil linked to my post on it)
The only part I had issue with was the password removal, never could get the line:
WAIT_LOADED="empty -w -t $SECONDS_TO_WAIT -i out.fifo -o in.fifo $PASS_PHRASE" # FOR nwnstartup.sh
to work satisfactorily. Maybe Skil can provide insight, the script is infinitely more powerful and useful than the basic one you had.
#6
Posté 01 mars 2011 - 06:07
Thanks guys ...right now Im having a problem lauching manually to test.
Im in the directory /home/dan/nwn then I type ./nwserver -module "my_mod _name_here" and get no such file or directory found for nwserver ???When I run ./fixinstall it works and says ready to run so what is the issue?
Im in the directory /home/dan/nwn then I type ./nwserver -module "my_mod _name_here" and get no such file or directory found for nwserver ???When I run ./fixinstall it works and says ready to run so what is the issue?
#7
Posté 01 mars 2011 - 08:00
And nwserver really is located in that directory and has the executable bit set? AFAIKS fixinstall only checks for nwn and nwmain, not for nwserver!
HTH
Greetings
Skildron
HTH
Greetings
Skildron
#8
Posté 01 mars 2011 - 08:14
The linux nwserver is in that directory .Not the nwserver.exe
Not sure what you mean by bit set?
Sorry total noob with linux...here is my skill level.
I turned on server Ubuntu 10.4 server edition and I know how to change directories and change permissions.
This is on a virtual server .
Not sure what you mean by bit set?
Sorry total noob with linux...here is my skill level.
I turned on server Ubuntu 10.4 server edition and I know how to change directories and change permissions.
This is on a virtual server .
Modifié par Knight_Shield, 01 mars 2011 - 08:25 .
#9
Posté 01 mars 2011 - 08:37
This may sound trivial, but did you try typing the full path of the module you are trying to open into the command?
#10
Posté 02 mars 2011 - 11:57
Linux doesn't use executables.
you start dealing with binaries and other such wondeful stuff. really you're just attempting to run the nwserver. For the moment forget file extentions as you know them in a windows world.
so you you want to run nwserver. You use:
./nwserver
Can you run nwserver without trying to load any module at the moment?
you start dealing with binaries and other such wondeful stuff. really you're just attempting to run the nwserver. For the moment forget file extentions as you know them in a windows world.
so you you want to run nwserver. You use:
./nwserver
Can you run nwserver without trying to load any module at the moment?
#11
Posté 02 mars 2011 - 01:23
yes this is what I typed exactly
examples
1 ./nwserver
2 ./nwserver -module "module_name"
both bring the no such file or directory....
??
examples
1 ./nwserver
2 ./nwserver -module "module_name"
both bring the no such file or directory....
??
#12
Posté 02 mars 2011 - 03:32
Really something like
Greetings
Skildron
bash: ./nwserver: No such file or directoryor is it this:
bash: ./nwserver: Permission deniedThe difference is, in the first case the file really is not present, in the second case, it is present, but has no executable permissions. If you do a
ls -alF, what output does ls give you?
Greetings
Skildron
#13
Posté 02 mars 2011 - 06:28
yeah seems odd, sounds like nwserver isn't installed, or it's installed somewhere else other than the directory you are trying to run from.
Skil's instructions including the LS will be important. Unless there's something drastically top secret, just put the contents of the LS into a quote box.
Skil's instructions including the LS will be important. Unless there's something drastically top secret, just put the contents of the LS into a quote box.
#14
Posté 02 mars 2011 - 09:13
Ok here is exactly what it does when I ./nwserver
-bash: ./nwserver: No such file or directory
I did also do the ls -alF but the list is long and blows down the whole page.I know there is away to slow it down but I forgot. I did see the nwserver file in green because I set the permissions to 775.
-bash: ./nwserver: No such file or directory
I did also do the ls -alF but the list is long and blows down the whole page.I know there is away to slow it down but I forgot. I did see the nwserver file in green because I set the permissions to 775.
#15
Posté 02 mars 2011 - 09:40
If Linux works like Unix, you can port it into a file using ls -alF > somefilename. The Linux guys will correct it if it is different in Linux.
#16
Posté 03 mars 2011 - 04:07
Pretty sure that works. Just piping it into a file instead of standard output (the screen).
Fairly certain you could also to ls -alF n*.*
Which would give you a listing of all files starting with n..
Fairly certain you could also to ls -alF n*.*
Which would give you a listing of all files starting with n..
#17
Posté 03 mars 2011 - 03:18
Ok here is what it shows by doing ls -alF n*.*
nwconfig.ini
nwconfig.exe
nwloader.exe
nwmain.exe
nwncdkey.ini
nwn.exe
nwnpatch.ini
nwnplayer.ini
nwserver.exe
nwtoolset.exe
nwtoolset.ini
nwupdate.ini
I see the nwserver when I do ls but not in this one ?
nwconfig.ini
nwconfig.exe
nwloader.exe
nwmain.exe
nwncdkey.ini
nwn.exe
nwnpatch.ini
nwnplayer.ini
nwserver.exe
nwtoolset.exe
nwtoolset.ini
nwupdate.ini
I see the nwserver when I do ls but not in this one ?
#18
Posté 03 mars 2011 - 07:21
haha hey guys does this make sense to you ?
sudo apt-get install ia32-libs
./nwserver not only worked but DM can login too. Thanks guys .
sudo apt-get install ia32-libs
./nwserver not only worked but DM can login too. Thanks guys .
Modifié par Knight_Shield, 03 mars 2011 - 08:10 .
#19
Posté 03 mars 2011 - 10:22
ahhh 64 bit environment.....
If you decide to run nwnx... I do have some binaries I compiled in 64 bit environment. I don't think you'll need them if you just want to run 32 bit precompiled SO.
If you decide to run nwnx... I do have some binaries I compiled in 64 bit environment. I don't think you'll need them if you just want to run 32 bit precompiled SO.
#20
Posté 06 mars 2011 - 02:25
Ok guys I have been looking at the script Skildron advised .I was going to call it restart and have a cron call it every 5 min to see if server needed rebooting.
I'm NOT using nwnx keep in mind.
Question : where does the name of my module go in this thing.And once thats figured out is the rest right and if i call it every 5 minutes?
Here it is >>>>>>>>>>>>>>>>>>>>>>>.
#!/bin/bash
#nwservctl.sh
#control command for nwn server, requires empty-expect
# **** BASIC CONFIGURATION ****
# Num of log directory to keep
LOG_HIST_NUM=9
# Seconds to wait for server loading
SECONDS_TO_WAIT=60
#Default Countdown in seconds
COUNTDOWN=60
# nwserver command: nwserver or nwnstartup.sh for NWNX2
#NWSERVER_COMMAND="nwnstartup.sh" #NWNX2
NWSERVER_COMMAND="nwserver" #Basic nwserver
FIRST_EXIT_PHRASE="Stopping server in"
SECOND_EXIT_PHRASE="seconds please logout..."
# output passfrase to wait for module loaded
#PASS_PHRASE="0x08203e79" # NWNX2 init if you use nwnstartup.sh
PASS_PHRASE="running" # Basic nwserver
# **** END BASIC CONFIGURATION ****
# **** ADVANCED CONFIGURATION ******
# ONLY FOR EXPERTS
# start server command
NWSERVER_START="empty -f -i in.fifo -o out.fifo ./$NWSERVER_COMMAND"
# wait for loaded command
WAIT_LOADED="empty -w -t $SECONDS_TO_WAIT -i out.fifo -o in.fifo $PASS_PHRASE" # FOR nwnstartup.sh
# return output from server command
# use a timeout until all commands are debugged
CATCH_OUTPUT="empty -r -t 30 -b 8192 -i out.fifo"
# first line argument
ARG1="$1"
# exit code
EXCODE=0
# *** CODE ***
#check if arguments exist
if [ "x$ARG1" = "x" ] || [ "x$ARG1" = "xusage" ] || [ "x$ARG1" = "x--help" ]; then
echo "Usage: `basename $0` start | restart [countdown [n]]" >&2
echo " `basename $0` stop [countdown [n]] | kill | status" >&2
echo " `basename $0` info [pid | pcpu | etime | pmem | vsz ] | --help" >&2
echo " `basename $0` <nwsever commands> if server is running" >&2
exit 1
fi
# check if nwserver is running exit if command is not
if [ "$(pidof nwserver)" ] ; then
if [ "x$ARG1" = "xstart" ] ; then
echo "`basename $0` - nwserver already running..."
exit 1
else
: # do nothing continue
fi
else
if [ "x$ARG1" = "xstart" ] ; then
: # do nothing continue
else
echo "`basename $0` - nwserver is not running..."
exit 1
fi
fi
case $ARG1 in
start)
# rotate logs
if [ -d "./logs/logs.$LOG_HIST_NUM" ]; then
rm -f -r "./logs/logs.$LOG_HIST_NUM"
fi
for ((ddest=$LOG_HIST_NUM; ddest >= 2 ; ddest--))
do
let "dsourc = $ddest - 1"
if [ -d "./logs/logs.$dsourc" ]; then
mv -f "./logs/logs.$dsourc" "./logs/logs.$ddest"
fi
done
#move log.0 in log.1
mv -f ./logs.0 ./logs/logs.1
mkdir ./logs.0
#end rotate logs
shift
NWSERVER_START="$NWSERVER_START $*"
$NWSERVER_START
echo "Starting nwserver please wait.."
sleep 5
$WAIT_LOADED
if [ "$(pidof nwserver)" ]
then
echo "nwserver is running now"
else
echo "nwserver loading failed.."
EXCODE=1
fi
;;
stop|restart)
if [ "x$2" = "xcountdown" ]
then
if [ "$3" -gt 0 ]
then
COUNTDOWN="$3"
fi
while [ "$COUNTDOWN" -gt 0 ]
do
$0 "say $FIRST_EXIT_PHRASE $COUNTDOWN $SECOND_EXIT_PHRASE"
let "COUNTDOWN -= 10"
sleep 10
done
fi
echo "exit" | empty -s -o ./in.fifo
$CATCH_OUTPUT
if [ "x$1" = "xrestart" ]
then
echo "restarting in 10 seconds pleas wait..."
sleep 10
$0 "start"
fi
;;
info)
case "$2" in
pcpu|etime|pmem|vsz)
ps -p "$(pidof nwserver)" -o "$2="
;;
pid)
echo "$(pidof nwserver)"
;;
*)
ps -p "$(pidof nwserver)" -o pid,comm,etime,pmem,vsz,pcpu
esac
;;
kill)
empty -k "$(pidof nwserver)"
;;
# with return output
status|help|listbans)
echo "$ARG1" | empty -s -o ./in.fifo
$CATCH_OUTPUT
;;
# no return output
playerpassword|dmpassword|adminpassword|oneparty|ilr|elc|difficulty|servername|autosaveinterval|pauseandplay|minlevel|maxlevel|maxclients|export|kick)
echo "$*" | empty -s -o ./in.fifo
#no output to catch
;;
#all other commands default send to nwserver
*)
echo "$*" | empty -s -o ./in.fifo
$CATCH_OUTPUT
esac
exit $EXCODE
I'm NOT using nwnx keep in mind.
Question : where does the name of my module go in this thing.And once thats figured out is the rest right and if i call it every 5 minutes?
Here it is >>>>>>>>>>>>>>>>>>>>>>>.
#!/bin/bash
#nwservctl.sh
#control command for nwn server, requires empty-expect
# **** BASIC CONFIGURATION ****
# Num of log directory to keep
LOG_HIST_NUM=9
# Seconds to wait for server loading
SECONDS_TO_WAIT=60
#Default Countdown in seconds
COUNTDOWN=60
# nwserver command: nwserver or nwnstartup.sh for NWNX2
#NWSERVER_COMMAND="nwnstartup.sh" #NWNX2
NWSERVER_COMMAND="nwserver" #Basic nwserver
FIRST_EXIT_PHRASE="Stopping server in"
SECOND_EXIT_PHRASE="seconds please logout..."
# output passfrase to wait for module loaded
#PASS_PHRASE="0x08203e79" # NWNX2 init if you use nwnstartup.sh
PASS_PHRASE="running" # Basic nwserver
# **** END BASIC CONFIGURATION ****
# **** ADVANCED CONFIGURATION ******
# ONLY FOR EXPERTS
# start server command
NWSERVER_START="empty -f -i in.fifo -o out.fifo ./$NWSERVER_COMMAND"
# wait for loaded command
WAIT_LOADED="empty -w -t $SECONDS_TO_WAIT -i out.fifo -o in.fifo $PASS_PHRASE" # FOR nwnstartup.sh
# return output from server command
# use a timeout until all commands are debugged
CATCH_OUTPUT="empty -r -t 30 -b 8192 -i out.fifo"
# first line argument
ARG1="$1"
# exit code
EXCODE=0
# *** CODE ***
#check if arguments exist
if [ "x$ARG1" = "x" ] || [ "x$ARG1" = "xusage" ] || [ "x$ARG1" = "x--help" ]; then
echo "Usage: `basename $0` start | restart [countdown [n]]" >&2
echo " `basename $0` stop [countdown [n]] | kill | status" >&2
echo " `basename $0` info [pid | pcpu | etime | pmem | vsz ] | --help" >&2
echo " `basename $0` <nwsever commands> if server is running" >&2
exit 1
fi
# check if nwserver is running exit if command is not
if [ "$(pidof nwserver)" ] ; then
if [ "x$ARG1" = "xstart" ] ; then
echo "`basename $0` - nwserver already running..."
exit 1
else
: # do nothing continue
fi
else
if [ "x$ARG1" = "xstart" ] ; then
: # do nothing continue
else
echo "`basename $0` - nwserver is not running..."
exit 1
fi
fi
case $ARG1 in
start)
# rotate logs
if [ -d "./logs/logs.$LOG_HIST_NUM" ]; then
rm -f -r "./logs/logs.$LOG_HIST_NUM"
fi
for ((ddest=$LOG_HIST_NUM; ddest >= 2 ; ddest--))
do
let "dsourc = $ddest - 1"
if [ -d "./logs/logs.$dsourc" ]; then
mv -f "./logs/logs.$dsourc" "./logs/logs.$ddest"
fi
done
#move log.0 in log.1
mv -f ./logs.0 ./logs/logs.1
mkdir ./logs.0
#end rotate logs
shift
NWSERVER_START="$NWSERVER_START $*"
$NWSERVER_START
echo "Starting nwserver please wait.."
sleep 5
$WAIT_LOADED
if [ "$(pidof nwserver)" ]
then
echo "nwserver is running now"
else
echo "nwserver loading failed.."
EXCODE=1
fi
;;
stop|restart)
if [ "x$2" = "xcountdown" ]
then
if [ "$3" -gt 0 ]
then
COUNTDOWN="$3"
fi
while [ "$COUNTDOWN" -gt 0 ]
do
$0 "say $FIRST_EXIT_PHRASE $COUNTDOWN $SECOND_EXIT_PHRASE"
let "COUNTDOWN -= 10"
sleep 10
done
fi
echo "exit" | empty -s -o ./in.fifo
$CATCH_OUTPUT
if [ "x$1" = "xrestart" ]
then
echo "restarting in 10 seconds pleas wait..."
sleep 10
$0 "start"
fi
;;
info)
case "$2" in
pcpu|etime|pmem|vsz)
ps -p "$(pidof nwserver)" -o "$2="
;;
pid)
echo "$(pidof nwserver)"
;;
*)
ps -p "$(pidof nwserver)" -o pid,comm,etime,pmem,vsz,pcpu
esac
;;
kill)
empty -k "$(pidof nwserver)"
;;
# with return output
status|help|listbans)
echo "$ARG1" | empty -s -o ./in.fifo
$CATCH_OUTPUT
;;
# no return output
playerpassword|dmpassword|adminpassword|oneparty|ilr|elc|difficulty|servername|autosaveinterval|pauseandplay|minlevel|maxlevel|maxclients|export|kick)
echo "$*" | empty -s -o ./in.fifo
#no output to catch
;;
#all other commands default send to nwserver
*)
echo "$*" | empty -s -o ./in.fifo
$CATCH_OUTPUT
esac
exit $EXCODE
#21
Posté 06 mars 2011 - 03:11
You'll see way at top there are two versions of the command to run nwserver. One is without nwnx, you simply append your servers options, etc to the nwserver command.
Or you could simpely create a nwnstartup.sh file and use the nwnx command (you don't need to have the plugin to have the server startup routine)
would looks something like this:
[nwscript]
#!/bin/sh
#export LD_PRELOAD="./nwnx2.so"
./nwserver \\
-publicserver 1 \\
-servername "Your Server Name" \\
-dmpassword pass \\
-oneparty 0 \\
-pvp 2 \\
-difficulty 3 \\
-elc 1 \\
-ilr 0 \\
-reloadwhenempty 0 \\
-module "Your Module" \\
-pauseandplay 0 \\
-maxclients 40 \\
-servervault 1 \\
-maxlevel 40 \\
-gametype 3 \\
-autosaveinterval 0 \\
-playerpassword blblbl \\
-port 5121 \\
"$@"
#unset LD_PRELOAD
exit
[/nwscript]
Or you could simpely create a nwnstartup.sh file and use the nwnx command (you don't need to have the plugin to have the server startup routine)
would looks something like this:
[nwscript]
#!/bin/sh
#export LD_PRELOAD="./nwnx2.so"
./nwserver \\
-publicserver 1 \\
-servername "Your Server Name" \\
-dmpassword pass \\
-oneparty 0 \\
-pvp 2 \\
-difficulty 3 \\
-elc 1 \\
-ilr 0 \\
-reloadwhenempty 0 \\
-module "Your Module" \\
-pauseandplay 0 \\
-maxclients 40 \\
-servervault 1 \\
-maxlevel 40 \\
-gametype 3 \\
-autosaveinterval 0 \\
-playerpassword blblbl \\
-port 5121 \\
"$@"
#unset LD_PRELOAD
exit
[/nwscript]
#22
Posté 06 mars 2011 - 03:13
As for the cron job, you would have it test your process monitor say.. every 5 minutes....
You simply have to change your restart command to ./nwservctl.sh start
You simply have to change your restart command to ./nwservctl.sh start
#23
Posté 07 mars 2011 - 02:13
I changed the line at the top like this
NWSERVER_COMMAND="nwserver -module mymodule" #Basic nwserver
comes back saying line 59 unknown token? here is line 59
case $ARG1 in
NWSERVER_COMMAND="nwserver -module mymodule" #Basic nwserver
comes back saying line 59 unknown token? here is line 59
case $ARG1 in
#24
Posté 07 mars 2011 - 09:01
You have to run the script as ./nwservctl start to start your nwserver instance. Other than that, adding the module name inside the script, which I never did before, as the script offers lots of possibilities to communicate with the running nwserver, works fine - I just tried it out.
Greetings
Skildron
Greetings
Skildron
#25
Posté 07 mars 2011 - 09:26
Might have issues parsing the string like that, unfortunately my linux test box is outta comission for a couple days so I can't offer any help, other than what I suggested earlier, create a nwnstartup.sh file like the example above.
Then simply have your process monitor launch the server if the pid doesn't exist anywhere. I wrote a slightly more detailed and elaborate process monitor than that, as mine will search to see if nwserver is hanging at maximum processor usage for more than 90 seconds if it is running.
Then simply have your process monitor launch the server if the pid doesn't exist anywhere. I wrote a slightly more detailed and elaborate process monitor than that, as mine will search to see if nwserver is hanging at maximum processor usage for more than 90 seconds if it is running.





Retour en haut







