Error running make install for the first time
Under Ubuntu, this is the error I got.
ps -ef | grep "services/movies.py" | grep -v grep | awk '{print $2}' | xargs kill
Usage:
kill [options] <pid> [...]
Options:
<pid> [...] send signal to every <pid> listed
-<signal>, -s, --signal <signal>
specify the <signal> to be sent
-l, --list=[<signal>] list all signal names, or convert one to a name
-L, --table list all signal names in a nice table
-h, --help display this help and exit
-V, --version output version information and exit
For more details see kill(1).
make: *** [shutdown] Error 123
The problem is related to the kill part, as this is my first time, there is no PID and therefore, kill complains.
Fixed by adding -r to the xargs. According to the man page: Do not run the command if there are no arguments. Normally the command is executed at least once even if there are no arguments.
Thanks for pointing this out. Unfortunately, -r switch is only available in the GNU variants and won't run on BSD based implementations like OSX.
Here's what I get on my mac when I try to execute the command:
ps -ef | grep "services/movies.py" | grep -v grep | awk '{print $2}' | xargs -r kill
xargs: illegal option -- r
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
[-L number] [-n number [-x]] [-P maxprocs] [-s size]
[utility [argument ...]]
make: *** [shutdown] Error 1
Links you might be interested in as you try to find a solution: http://stackoverflow.com/questions/17402345/ignore-empty-results-for-xargs-in-mac-os-x http://stackoverflow.com/questions/18812766/dont-call-xargs-if-the-previous-command-doesnt-return-anything
Found the same thing in oh-my-zsh, I think this is a cleaner way. Can you check this patch now works in OSX?
Here is my windows info, I append -f to fix this, but it seems no such option in other platform.
/d/src/microservices {develop} $ make install
ps -ef | grep "services/movies.py" | grep -v grep | awk '{print $2}' | xargs kill
Usage: kill [-f] [-signal] [-s signal] pid1 [pid2 ...]
kill -l [signal]
Send signals to processes
-f, --force force, using win32 interface if necessary
-l, --list print a list of signal names
-s, --signal send signal (use kill --list for a list)
-h, --help output usage information and exit
-V, --version output version information and exit
make: *** [shutdown] Error 123
after I change command like this: ps -ef | grep "services/movies.py" | grep -v grep | awk '{print $2}' | xargs kill -f, this target works.
append this to the xargs command within the "makefile" file to fix it. --no-run-if-empty
result lines: shutdown: ps -ef | grep "services/movies.py" | grep -v grep | awk '{print $$2}' | xargs --no-run-if-empty kill ps -ef | grep "services/showtimes.py" | grep -v grep | awk '{print $$2}' | xargs --no-run-if-empty kill ps -ef | grep "services/bookings.py" | grep -v grep | awk '{print $$2}' | xargs --no-run-if-empty kill ps -ef | grep "services/user.py" | grep -v grep | awk '{print $$2}' | xargs --no-run-if-empty kill