Hi Guys,
working with some java batch programs I needed to configure the anything
resource agent. I found that there's no way to define the working
directory from where the executable must be launched.
So I solved my problem patching the resource agent to support the
"workdir" parameter, by writing this patch:
I don't know if this is the best solution (any suggestion will be
appreciated), but for me it worked, so I share it (you can find it
attached).
Bye,
--
Raoul Scarazzini
Mia Mamma Usa Linux: Niente รจ impossibile da capire, se lo spieghi bene!
mobile: +393281776712
[email protected]
http://www.miamammausalinux.org
--- ../heartbeat/anything 2010-07-15 11:26:18.000000000 +0200
+++ anything 2010-10-29 11:04:44.000000000 +0200
@@ -27,6 +27,7 @@
# OCF instance parameters
# OCF_RESKEY_binfile
# OCF_RESKEY_cmdline_options
+# OCF_RESKEY_workdir
# OCF_RESKEY_pidfile
# OCF_RESKEY_logfile
# OCF_RESKEY_errlogfile
@@ -34,7 +35,7 @@
# OCF_RESKEY_monitor_hook
# OCF_RESKEY_stop_timeout
#
-# This RA starts $binfile with $cmdline_options as $user and writes a $pidfile from that.
+# This RA starts $binfile with $cmdline_options as $user in $workdir and writes a $pidfile from that.
# If you want it to, it logs:
# - stdout to $logfile, stderr to $errlogfile or
# - stdout and stderr to $logfile
@@ -74,14 +75,14 @@
if [ -n "$logfile" -a -n "$errlogfile" ]
then
# We have logfile and errlogfile, so redirect STDOUT und STDERR to different files
- cmd="su - $user -c \"nohup $binfile $cmdline_options >> $logfile 2>> $errlogfile & \"'echo \$!' "
+ cmd="su - $user -c \"cd $workdir; nohup $binfile $cmdline_options >> $logfile 2>> $errlogfile & \"'echo \$!' "
else if [ -n "$logfile" ]
then
# We only have logfile so redirect STDOUT and STDERR to the same file
- cmd="su - $user -c \"nohup $binfile $cmdline_options >> $logfile 2>&1 & \"'echo \$!' "
+ cmd="su - $user -c \"cd $workdir; nohup $binfile $cmdline_options >> $logfile 2>&1 & \"'echo \$!' "
else
# We have neither logfile nor errlogfile, so we're not going to redirect anything
- cmd="su - $user -c \"nohup $binfile $cmdline_options & \"'echo \$!'"
+ cmd="su - $user -c \"cd $workdir; nohup $binfile $cmdline_options & \"'echo \$!'"
fi
fi
ocf_log debug "Starting $process: $cmd"
@@ -169,6 +170,7 @@
process="$OCF_RESOURCE_INSTANCE"
binfile="$OCF_RESKEY_binfile"
cmdline_options="$OCF_RESKEY_cmdline_options"
+workdir="$OCF_RESKEY_workdir"
pidfile="$OCF_RESKEY_pidfile"
[ -z "$pidfile" ] && pidfile=${HA_VARRUN}/anything_${process}.pid
logfile="$OCF_RESKEY_logfile"
@@ -225,6 +227,13 @@
<shortdesc lang="en">Command line options</shortdesc>
<content type="string" />
</parameter>
+<parameter name="workdir" required="1" unique="1">
+<longdesc lang="en">
+The path from where the binfile will be executed.
+</longdesc>
+<shortdesc lang="en">Full path name of the executable directory</shortdesc>
+<content type="string" default=""/>
+</parameter>
<parameter name="pidfile">
<longdesc lang="en">
File to read/write the PID from/to.
_______________________________________________
Linux-HA mailing list
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems