How to redirect program logs to file

It's my rc file: idf_http,
Then run $ tail -f /var/log/idf_http.log, don't see anything in realtime.
But if I stop the idf_http service # service idf_http stop, the logs will output to the terminal.

Code:
#! /bin/sh
#
#

# PROVIDE: idf_http
# REQUIRE: LOGIN postgresql nginx
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf to enable idf_http:
#
#idf_http_enable="YES"

. /etc/rc.subr

name="idf_http"
rcvar="idf_http_enable"
logfile="/var/log/${name}.log"
idf_http_chdir="/usr/home/pili/projects/idatafun/release"
idf_http_command="/usr/home/pili/projects/idatafun/release/idf-http"
pidfile="/var/run/${name}.pid"
command="/usr/sbin/daemon"
#command_args="-P ${pidfile} ${idf_http_command} -o ${logfile}" # cant log to file
command_args="-P ${pidfile} ${idf_http_command} > ${logfile} 2>&1"

load_rc_config $name
: ${idf_http_enable:=no}
: ${idf_http_env:="RUST_LOG=info"}

run_rc_command "$1"
 
Fixed.

I changed to command_args="-m 3 -S -f -o ${logfile} -P ${pidfile} -r ${idf_http_command}"
 
Back
Top