Detect the rails zeus start complete - ruby-on-rails

I have 2 terminals running, and I'd like to run
#on term1
zeus start
#on term2
zeus server
The problem is that normally it should wait for the start process to complete.
My question is how could I make the second terminal to auto start the server after the zeus start complete?
I've tried sleep 2 ...but there should be better way.
Thanks

I am not sure there is something else than a hacky way for this. As stated in zeus's roadmap, starting the server whithout having to start zeus before is planned for version 2...
If you want a hacky way, you can play with a little shell script like the following:
while [[ "`ps aux | grep "zeus slave" | wc -l`" == "1" ]]; do sleep 1; done; zeus server

Related

Have Jenkins force quit cucumber script if new build is pushed

So I am using Ruby/Cucumber and Appium to run automated tests after each of our builds on our Jenkins server.
Essentially I have a job set up that runs our regression suite after every build that is successful. My problem comes in when my cucumber tests are running and a new build is successful.
At the moment Jenkins will start a new series of tests with the cucumber script, but won't force the old script to quit. This leads to all of my cucumber reports showing multiple false negatives. Is there a way to stipulate that Jenkins run a script that quits cucumber before starting a new set of tests?
Thanks a ton for any help you can give me. If you have any questions about how I have Jenkins set up specifically just ask and I'll give you the more intimate details.
Technically Jenkins Job will wait for 1 instance of job to complete until it starts another one. So you dont have to worry about starting another build before first one finishes...
Now coming to your question how to kill old/existing test cases if a set of new ones want to start.
I would suggest to have a cleanup script run before your actual tests are triggered, your tests would be triggering using a rake or direct cucumber command, I am guessing. So before this happens, have a cleanup.sh executed which will do the following:
1) Restart appium server.
2) Kill running ruby processes.
3) Kill running cucumber processes.
The script should look something like this:
kill -9 $(ps -ef | grep \[a]ppium | awk '{print $2}')
kill -9 $(ps -ef | grep \[r]uby | awk '{print $2}')
kill -9 $(ps -ef | grep \[c]ucumber | awk '{print $2}')
# restart appium again
appium &
Hope it helps!! Let me know in comments if you run into issues.. :)

Is it possible to install timeout in OpenWRT

I need to execute a command with a timeout in OpenWRT, but it seems that the command timeout is not installed by default neither can be installed using opkg. I know that I can do a work around (using command &; sleep $DELAY; kill $!), but I wish to do this more properly without getting the risk of kill trying to kill a process in case the command finished before the timeout.
Yes you can install timeout on openWRT
$ opkg update
$ opkg install coreutils-timeout
$ timeout 2 sleep 10
This has been tested with AA, pretty sure that would also work with BB.
In short: it is not possible. I have to do it using sleep && kill.
timeout is a shell command so it executes in a subshell
timeout 6 sleep 20 will work if executed in direct shell terminal but same command won't work if initiated from a shell script.
So to run timeout in a shell script , use like this
out="$(timeout 6 sleep 20)"
OR
echo "$(timeout 10 sleep 20)"
this will run your timeout and your command in one subshell

Start god process on server startup (Ubuntu)

I'm currently struggling with executing a simple command which I know works when I run it manually when logged in as either root or non-root user:
god -c path/to/app/queue_worker.god
I'm trying to run this when the server starts (I'm running Ubuntu 12.04), and I've investigated adding it to /etc/rc.local just to see if it runs. I know I can add it to /etc/init.d and then use update-rc.d but as far as I understand it's basically the same thing.
My question is how I run this command after everything has booted up as clean as possible without any fuzz.
Im probably missing something in the lifecycle of how everything's initialized, but then I gladly encourage some education! Are there alternative ways or places of putting this command?
Thanks!
You could write a bash script to determine when Apache has started and then set it to run as a cron job at a set interval...
if [ "$(pidof apache)" ]
then
# process was found
else
# process not found
fi
Of course then you'll have a useless cron job running all the time, and you'll have to somehow flip a switch once it's run once so it doesn't run again.. This should give you an idea to start from..

Script to HUP parent and child process

I need a shell script to send a HUP to the parent and child processes.
I am using freeBSD with tcsh? #/bin/sh
Somehow, I need to pipe the PID output from pgrep to kill -HUP in a loop in a shell script.
Ultimately I want to run this script as a cron job.
I just don't have the skills yet.
Thanks - Brad
(This isn't a complete answer, but I can't make comments without at least 50 reputation apparently).
First of all, /bin/sh on FreeBSD is a Boune-compatible shell, not tcsh (which is /bin/tcsh). A start would be something like the following:
#!/bin/sh
for pid in $(pgrep <process name>); do kill -HUP $pid; done
Without more details, I can't really say much more.

script to start erlang code

I am trying to build a script on ubuntu to start some Erlang code of mine:
the script is something like:
#!/bin/sh
EBIN=$HOME/path_to_beams
ERL=/usr/local/bin/erl
export HEART_COMMAND="$EBIN/starting_script start"
case $1 in
start)
$ERL -sname mynode -pa $EBIN \
-heart -detached -s my_module start_link
;;
*)
echo "Usage: $0 {start|stop|debug}"
exit 1
esac
exit 0
but I'm having a couple of problems.
First of all, the code can be executed only if the script is in the same directory as the beams, this seems strange to me, I double checked the paths, so why doesn't the -pa flag work?
Second, the script (without the -pa) works fine, but if I try to start instead of the main module (a gen_server) its supervisor (-s my_module_sup start_link) it doesn't work...this is strange, because if I start the supervisor from a normal shell everything works fine.
Third, the -heart flag, should restart the script in case of failure, but if I kill the process with a normal Unix kill, the process is not restarted.
Can someone give me some hints?
Thanks in advance,
pdn
The first thing that comes to mind is that you're using erlexport instead of erl. Not sure why you're doing this (I've not heard of erlexport before). Try it with erl instead.
Your -heart flag won't have meaning if the Erlang node itself is killed because the process can't keep itself alive. You would need another process running that monitors the Erlang process and restarts it if killed.

Resources