Kill yarn application by Application-Name - hadoop-yarn

I want to create a cron to kill a yarn application (Spark) by it application name. But i found thant yarn application -kill needs an application ID. Is there a solution to kill it by application name, or to get the application ID using the application name.
Thank you

The output of the 'yarn application -list' contains the following information of yarn applications:
Application-Id
Application-Name
Application-Type
User
Queue
State
Final-State
Progress
Tracking-URL
You can list the applications and awk by the required parameter.
For ex: to list the applications by 'Application-Name'
yarn application -list | awk '$2 == "APPLICATION_NAME" { print $1 }' > applications_list.txt
Then you can iterate through the file and kill the applications as below:
while read p; do
echo $p
yarn application -kill $p
done <applications_list.txt

yarn application -list
This will give you a list of the applications, with application ID, running on yarn.

The same answer as others but with using xargs
yarn application -list | awk '$2 == "APPLICATION_NAME" { print $1 }' | xargs yarn application -kill

Related

Gitlab-ci runner hangs after cypress tests

I am using gitlab-ci to tests a react application with cypress.
The test seems to pass but it hangs after executing cypress run command.
Thus, the test fails because of the timeout.
My service is the following
cypress:
image: cypress/base:10
script:
- serve -s build -l 3000 & yarn wait-on http://localhost:3000
- yarn cypress:run
And in my package.json
{
...
"scripts": {
"cypress:run": "cypress run --spec 'cypress/integration/**/*spec.js' --record false --config video=false"
},
...
}
This is the end of gitlab-ci runner's log:
✔ All specs passed! 01:01 11 11 - - -
Done in 73.82s.
ERROR: Job failed: execution took longer than 20m0s seconds
this issue occurs when a background task is running in the runner
To fix this I put in an or condition on the cypress:run step and kill the process if the result is not a success
there is another kill statement added in the step below also in case -parallel is used and multiple steps are running
Something like this
script:
# start the server in the background
- npx serve -s build -p 3001 &
# run Cypress tests in parallel
- yarn cypress:run || (ps -ef | grep [s]erve| awk '{print $2}' | xargs kill -9 )
- (ps -ef | grep [s]erve| awk '{print $2}' | xargs kill -9 ) || exit 0
I don't know if this can help someone, but it is worth to try updating node.
I had the same problem when using cypress 11.1.0 and node:16.17.1-slim docker image. I do not experience hang ups with node:16.18.1-slim anymore.
P.S. Along with node update I've updated Chrome from 106 to 107, so can't be sure what actually made the trick, just wanted to share with possible solution.

Why does this fish while loop terminate after a single iteration?

This is a fish function used to upgrade JavaScript packages for a project. Strangely, it terminates after a single iteration with an exit status of 0. Why?
function yarn-upgrade-all --description "Upgrade JavaScript packages"
yarn outdated | sed '1,/^Package/d;/^Done/d' | awk '{print $1, $4}' | while read -l PACKAGE VERSION
echo
set_color brwhite
echo -n "==>"
set_color yellow
echo -n " "$PACKAGE
set_color brblue
echo -n " "$VERSION
set_color brwhite
echo -n " <=="
set_color normal
echo
echo
yarn upgrade --latest $PACKAGE
and yarn run test
and yarn run build
and git commit -am "Upgrade to "$PACKAGE" "$VERSION
or begin
set_color red
echo "last command exited with status $status" >&2
set_color normal
return 1
end
end
end
On the other hand, this second function, which contains only a stub body, runs through all packages piped into the loop.
function yarn-upgrade-all-debug --description "Upgrade JavaScript packages"
yarn outdated | sed '1,/^Package/d;/^Done/d' | awk '{print $1, $4}' | while read -l PACKAGE VERSION
echo $PACKAGE $VERSION
end
end
fish --version
fish, version 3.0.2
You're running fish 3.0.0, and hitting https://github.com/fish-shell/fish-shell/issues/5513 - return from a while doesn't actually set the status correctly.
However, the return still causes it to terminate the while-loop.
Upgrade to 3.0.2.
The loop terminates after a single iteration because the yarn run invocations in the loop body slurp up the rest of stdin. (Credits to #glenn-jackman.)
A possible workaround is to redirect stdin to /dev/null for these commands:
and yarn run test < /dev/null
and yarn run build < /dev/null
The culprit is run-s from the npm-run-all package, which is invoked by both yarn run commands.
https://github.com/mysticatea/npm-run-all/issues/166

Bash script in Mac OS X app, calling custom app from system

In my bash script i have:
program=*program_name*
condition=$(which $program 2>/dev/null | grep -v "not found" | wc -l)
if [ $condition -eq 0 ] ; then
echo "$program is not installed";
echo -n *mypass* |sudo -S gem install $program;
fi
First of all, it installs program every time. It shows that program is not installed, but i can use it from terminal.
...then, i need to use this program in my cocoa application, for example
program --help
Using
system([pathToFile UTF8String]);
i get:
path_to_bundle/myBashScript.sh: Permission denied // Where path is in bundle
path_to_folder/myBashScript.sh:line 30: program: command not found // Where path is from other system folder
Using NSTask i get program: command not found every time.
I don't understand why this is happening. And i would like to know how i can use this program in my cocoa app.
So, i have found the solution.
When you're trying to run the custom system program from the cocoa app, you should give the full path to the binary.
The problem is in:
program=*program_name*
*program_name* should be full path to binary, in my case it was /Library/Ruby/Gems/2.0.0/gems/program-version/bin/program
For additional information about installation paths:
https://wiki.haskell.org/Mac_OS_X_Common_Installation_Paths
http://help.rubygems.org/discussions/problems/739-how-to-run-applications-installed-by-gem

Apache Ace as a Service

I am trying to setup/configure Apache ACE for the first time. It seems like I got everything running correctly but I would like to have ACE startup automatically when the Linux box starts. I created the init.d script below which does starts up ACE however it drops me in an OSGI console and when I leave the console ACE shuts down.
Is there a way to start ACE without having the OSGI console so I do not have to keep my session open to keep ACE running?
#! /bin/bash
BIN_DIR=/opt/ace-current/server-allinone
PATH=/bin:/usr/bin:/sbin:/usr/sbin
JAVA_HOME=/usr/lib/jvm/default-java
if [ `id -u` -ne 0 ]; then
echo "You need root privileges to run this script"
exit 1
fi
. /lib/lsb/init-functions
if [ -r /etc/default/rcS ]; then
. /etc/default/rcS
fi
case $1 in
start)
cd $BIN_DIR
java -Dorg.apache.ace.server=localhost:11868 -Dorg.osgi.service.http.port=11868 -Dorg.apache.ace.obr=localhost:11868 -jar server-allinone.jar
;;
stop)
pid=`ps aux | grep server-allinone | awk '{print $2}'`
kill -9 $pid
;;
restart)
$0 stop
$0 start
;;
esac
exit 0
java -Dgosh.args=--nointeractive -jar server-allinone.jar
Will disable the local shell.

nodejs, run test automatically when files change

Is there a way to automatically run tests, when a file in the app is changed? In rails there is a gem called guard. How can one achieve the same in nodejs?
Not sure if this would work for tests, but Nodemon (https://github.com/remy/nodemon) looks like what you want.
Install Jasmine and run
jasmine-node <dir> --autotest
Try this
touch /tmp/nt; while [ true ]; do if [ find . -newer /tmp/nt -type f
| grep -v app/cache | wc -l -gt 0 ]; then phpunit; touch /tmp/nt; fi;
sleep 5; done
I'm using it to autostart phpunit. Replace phpunit with the command to run tests
replace sleep 5 with sleep 1 if you wish to check every second (depends on the size of your files)