I was trying to start the jobserver.It fails and i dont see any logs for ERROR
/usr/share/dse/spark/spark-jobserver
./server_start.sh: line 41: kill: (21556) - No such process
You need to start it with the dse command
dse spark-jobserver start [any_spark_submit_options] //Start the job server
dse spark-jobserver stop //Stop the job server
https://docs.datastax.com/en/datastax_enterprise/4.8/datastax_enterprise/spark/sparkJobserverOverview.html
If that doesn't fix it it probably means a false start or improper shutdown has left a spark-jobserver.pid file in the spark-jobserver resource dir. Remove this so that the following code can pass.
if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE"); then
echo 'Job server is already running'
exit 1
fi
This code is checking to see if that PID file exists and if it does it tries to get info from the process. If the process doesn't exist then that means the pid file is there in error and must be removed (or you lack permission).
Related
I have been looking for a long time to see if anyone has had an answer to my issue, but it doesn't seem to exist. I recently found I rarely used M1 Mac Mini. Since I had barely used it, I decided to turn it into a functioning server that runs 24/7. The only issue is that sometimes while I'm sleeping and my friends are playing, the server crashes, and there's no way of starting it back up unless I'm awake. So I'm looking for help on how to make a .command file that either A.) It Pings the server every minute, and if it senses it's down, it terminates the current terminal and restarts the start command. B.) Once the server crashes and the terminal ends, it restarts. I prefer to go with option A, but I'll take any help that I get! Thank you so much in advance, everyone!
I tried a script online, and one of them goes like this.
while true
do
cd Desktop
cd server
/Library/Internet_Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -Xmx7G -Xms7G -jar forgeserver.jar
echo "If you want to completely stop the server process now, press Ctrl+C before
the time is up!"
echo "Rebooting in:"
for i in 5 4 3 2 1
echo "$i..."
sleep 1
done
echo "Rebooting now!"
done
However I am met with this error
Last login: Thu Feb 9 02:37:12 on ttys001
/Users/myname/Desktop/start.command ; exit;
davidking#Davids-Mac-mini ~ % /Users/myname/Desktop/start.command ; exit;
/Users/davidking/Desktop/start.command: line 11: syntax error near unexpected token `echo'
'Users/davidking/Desktop/start.command: line 11: `echo "$i..."
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[Process completed]
You can try something like that:
while true; do
ping -c 1 -W 1 your_server_IP
if [ $? -eq 0 ]; then
echo "Server is up"
else
echo "Server is down, restarting..."
# Add your server restart command here
/path/to/restart/command
fi
sleep 60
done
The ping -c 1 -W 1 your_server_IP command sends one Echo Request packet to your_server_IP, and waits for a response for 1 second. If a response is received, it means the server is up and running. If no response is received, it means the server is down.
You have to save this file as a .command file and add it to your PATH.
Let me know if it works or you're getting errors! I'll be happy to help :)
I have the following Jenkins post-build shell script:
ssh user#my_server <<EOF
service my_service stop
service my_service start
tail -f /opt/services/my_service/logs/current
exit
EOF
This script restarts my_service on a remote host (my_server).
My problem is: command service my_service start just makes a request to RUNIT to run a my_service, i.e service my_service start returns immediately after execution.
But service my_service start runs a SpringBoot java web application that writes all log info into .../logs/current log file. To catch this log info I've added command tail -f /opt/services/my_service/logs/current but in this case Jenkins build is never ends)) such as tail -f command never stops.
Is there a way to execute my post-build script (which only start my web app on a remote server) and grabbing the .../logs/current log file during 2 minutes or until this log has the line "Web app MyApplication has been Started".
I wanna see the content of .../logs/current log file right in Jenkins's Console output and kill tail -f after 2 minutes
tail -f will not end until it gets interrupted, so your script will never finish running.
what you can do is use grep -q on your log, which will exit with 0 exit status when it finds it's pattern:
grep -q 'Web app MyApplication has been Started' <(tail -f /opt/services/my_service/logs/current)
I am using a War file to deploy my application in Xampp. The thing is that since I update the code multiple times I need to replace the war file and restart the Apache, tomcat services. I thought of using a batch file for this to save time.
I'm doing the following 3 steps to deploy a war file.
1) Stop Apache & Tomcat services.
2) Delete existing war file and it's corresponding folder.
3) Start Apache & Tomcat services.
Batch Script..
echo "+++Deploy source in $PWD+++"
echo "+++ Shutting down tomcat ..."
call apache_stop.bat
call catalina_stop.bat
timeout 5 > NUL
echo "+++ Installing new war ..."
DEL "C:\xampp\tomcat\webappss\flsv2*"
xcopy /s C:\Users\Hp\git\flsv2-lucy\build/flsv2.war C:\xampp\tomcat\webapps
echo "+++ Starting up tomcat ..."
call apache_start.bat
call catalina_start.bat
timeout 5 > NUL
Unfortunately the above code is not working. Whenever I run the above script from the xampp folder I'm getting an error message in cmd prompt..
Error Message...
C:\xampp>deploy_local.bat
C:\xampp>echo "+++Deploy source in $PWD+++"
"+++Deploy source in $PWD+++"
C:\xampp>echo "+++ Shutting down tomcat ..."
"+++ Shutting down tomcat ..."
C:\xampp>call apache_stop.bat
pv: No matching processes found
Mysql shutdowm ...
pv: No matching processes found
"+++ Starting up tomcat ..."
C:\xampp>
Where am I going wrong??
There are a few things that strike my eye:
$PWD is linuxstyle. Use %cd% in Windows batch files for the same thing.
Maybe you want to add #echo off as first line in your script to prevent the double echo-ing of each line to console.
The error message "pv: No matching processes found" comes from apache_stop.bat. You need to trace/debug that script for further details. (You might want to add a #echo on in the first line to get every output).
Your output shows no sign of the deleting operations ("Installing new war"), I wonder why but suspect the errors popping up from apache_stop.bat. However, the output from the "Starting up tomcat" is there. Is the delete part working as expected? Do files get deleted?
Hint: If you use del with wildcards (*) you can/need to specify the /Q switch to prevent the confirmation prompt. See del /? on the command line for details.
Also on del, you might want to use *.* to get "any filename followed by any extension". Currently with the single asterisk the del command is looking for filenames "beginning with flsv2 with no extension". The asterisk wildcard is handled differently by Unix/Linux and Windows.
Recommendation: The xcopy command should have the paths quoted (mandatory if your paths contain spaces).
I am trying to write an init script for a java program. The program has no ability to background itself, so I'm using & to do it. It writes its logfiles to stdout.
The problem I have is regarding the RETVAL in the init script. Here's the function I'm using:
JAR_FILE=/opt/application/server/server.jar
JAVA=/usr/bin/java
start() {
echo -n $"Starting ${NAME}: "
daemon --pidfile=${PID_FILE} --user $USER \
$JAVA $JAVA_ARGS >> /var/log/application/server.log &
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $LOCKFILE
return $RETVAL
}
When I run the init script, the app starts up or fails nicely, the problem is that the retval is being written to the logfile, rather than to stdout:
[root#rpmbuild rpmbuild]# /etc/init.d/application-server start
Starting application-server:
[root#host]# tail /var/log/application/server.log
JAVA APPLICATION ERRORS ARE HERE
[FAILED]
Is there anyway I can make it log to stdout and also ensure that any retval (whether it good or bad) gets echoed to stdout?
There are options on how to direct the output when using the daemon command
-l, --errlog=spec - Send daemon's error output to syslog or file
-b, --dbglog=spec - Send daemon's debug output to syslog or file
-o, --output=spec - Send client's output to syslog or file
-O, --stdout=spec - Send client's stdout to syslog or file
-E, --stderr=spec - Send client's stderr to syslog or file
I would change the output using the -o option and not redirect. You should not have to background the task either
daemon -o /var/log/application/server.log -name SuperJavaProgram \
--pidfile=${PID_FILE} --user $USER $JAVA $JAVA_ARGS
Then you could test if it's running with daemon --running -n SuperJavaProgram
Maybe, you could print to stderr in java, to separate standard logs and errors. Your >> will redirect only stdout.
BTW, it's surprising to test $? whereas your program as not executed yet, because background-ed.
I have set up an automated deployment script (in shell script) for my web application.
It uses java, tomcat, maven and a postgres database.
The deployment script does this:
builds the deployable application from source repository
stops tomcat
applies database migration patches
deploys the war files in tomcat
starts tomcat (by invoking $TOMCAT_HOME/bin/startup.sh)
exits with a success message
It's all working and it's pretty neat - but it needs a little improvement.
You see, even though it exits with a success message, sometimes the deploy was not successful because the web application did not start correctly.
I would like to refactor steps 5 and 6 so that after bring up the tomcat server, the deployment script would "tail -f" in the catalina.out file, looking either for a "server started successfully" message or an exception stack trace.
The tail -f output up to that point should be part of the output of the deployment script, and step 6 would "exit 0" or "exit 1" accordingly.
I know that should be possible, if not in shell script, maybe with python.
The problem is I'm a java specialist - and by specialist I mean I suck at everything else :-)
Help please? :-)
Maybe something like this?
tmp=$(mktemp -t catalina.XXXXXXX) || exit 136
trap 'rm "$tmp"' 0
trap 'exit 255' 2 15
tail -n 200 catalina.out >"$tmp"
if grep -q error "$tmp"; then
cat "$tmp"
exit 1
fi
exit 0
On the other hand, if startup.sh were competently coded, you could just
if startup.sh; then
tail -f catalina.out
else
exit $?
fi
which can be shortened to
startup.sh || exit $?
tail -f catalina.out
As an alternative, you might want to take a look at the Apache Tomcat Manager application. It supports, amongst other things:
Deploying applications remotely, and from local paths
Listing currently deployed applications
Reloading existing applications
Starting an existing application
Stopping an existing application
Undeploying an existing application
The manager provides a web interface that can be called via curl, and which returns simple, parseable messages to indicate the status of the invoked command. Management functions can also be invoked via JMX, or Ant scripts. All in all, a very handy tool.
I ended up implementing a solution using Python's subprocess.Popen, as suggested by #snies.
Here's what it looks like:
waitForIt.py
#! /usr/bin/env python
import subprocess
import sys
def main(argv):
filename = argv[1]
match=argv[2]
p = subprocess.Popen(['tail', '-n', '0', '-f', filename], stdout=subprocess.PIPE)
while True :
line = p.stdout.readline()
print line ,
if match in line :
break
p.terminate()
if __name__ == "__main__":
main(sys.argv)
tailUntil.sh
#!/bin/bash
set -e
filename=$1
match=$2
thisdir=$(dirname $0)
python $thisdir/waitForIt.py "$filename" "$match"
and then
startTomcat.sh
${TOMCAT_HOME}/bin/startup.sh
logDeploy.sh "Agora vamos dar um tail no catalina.out..."
util_tailUntil.sh "$TOMCAT_HOME/logs/catalina.out" 'INFO: Server startup in '
It doesn't do what I originally intended (it still exits with return code 0 even when there is a stacktrace - but that could be changed with a little bit more of Python magic),
but all of tomcat's initialization log is part of the automated deploy out (and easily viewable on Jenkins' deploy job) -
so that's good enough.