Ok, so I am trying to execute the following code:
`#{@daemon_path} --name=#{@app_name} --command=#{@java_path} -- -jar #{jetty_jar} #{@war_path} #{random_port}` sleep(10) #give war time to error out and die if its going to `#{@daemon_path} --running --name=#{@app_name}`
The variables values are:
I get this error (checked commands in bash, they work fine):
Invalid arguments: no command supplied
usage: daemon [options] [--] [cmd arg...]
I fixed the above error by putting quotes around the above commands as follows:
"`#{@daemon_path} --name=#{@app_name} --command=#{@java_path} -- -jar #{jetty_jar} #{@war_path} #{random_port}`"
"`#{@daemon_path} --running --name=#{@app_name}`"
Ok, so after the code executes, i check the output with $? and notice a 0 return code. It should be 1. I ran it in bash and I get a 1. If I manually place in all of the correct values for each variable, it works correctly.
Furthermore, If i execute a script, passing in all of the values like so:
`./daemon_script_file #{@daemon_path} #{@app_name} #{@java_path} #{jetty_jar} #{@war_path} #{random_port}`
to the script daemon script file:
#!/bin/bash
set -x
d_bin=$1
name=$2
cmd=$3
jar=$4
war=$5
port=$6
$d_bin --name=$name --command=$cmd -- -jar $jar $war $port
sleep 10
$d_bin --name=$name --running
result=$?
exit $result
I get the following debug trace output:
+ d_bin=/usr/bin/daemon
+ name=
+ cmd=
+ jar=
+ war=
+ port=
+ /usr/bin/daemon --name= --command= -- -jar
+ sleep 10
+ /usr/bin/daemon --name= --running
+ result=1
+ exit 1
sh: 2: foobarbazquux: not found
invalid file (bad magic number): Exec format error
Does anyone have any clues as to why? Am i doing something incredibly stupid here?
just as a side note, the string:
"#{@daemon_path} --name=#{@app_name} --command=#{@java_path} -- -jar #{jetty_jar} #{@war_path} #{random_port}"
resolves to:
"/usr/bin/daemon --name=foobarbazquux --command=/usr/java/jdk1.7.0_21/bin/java -- -jar /home/nterry/JettyContainer-1.0.b4-jar-with-dependencies.jar /home/nterry/helloworld.war 8080"
Which is exactly correct
@Casper: You were correct. @daemon_path ended with an invalid character Thank you so much.