如果用默认的resin/bin/httpd.sh启动resin,只能启动一个resin。怎么才可以启动多个?
resin启动时是根据配置文件指定的端口来监听网络的,启动时指定不同的配置文件,配置文件又用不同的监听端口就可以了。
举例,copy一份resin.conf,修改其中的两个端口,
一个是http服务的端口<http address="*" port="8080"/>,
一个是管理端口和服务名<server id="svrname" address="127.0.0.1" port="6800"/>。
然后启动时指定配置文件:
${resinhome}/bin/httpd.sh -conf ${resinhome}/conf/${svrname}.conf -server $svrname
svrname是服务id和配置文件的名称(假设是相同的)。
为了区别不同服务的日志,还要改一个地方:
<log name="" level="fine" path="stdout:" timestamp="[%H:%M:%S.%s] "/> <stdout-log path="${resin.home}/log/svrname.log" archive-format="svrname-%Y_%m_%d.log" rollover-period="1D" rollover-size="1mb"/> <stderr-log path="${resin.home}/log/svrname.log" archive-format="svrname-%Y_%m_%d.log" rollover-period='1D' rollover-size='1mb'/>
进一步,可以写一个脚本改进resin的启动。先写一个newhttpd.sh:
svrname=$1 action=$2 logaction=$3 resinhome="${HOME}/resin" ${resinhome}/bin/httpd.sh -conf ${resinhome}/conf/${svrname}.conf -server $svrname $action if [ "${logaction}" == "tail" ] ; then echo ******start tailing log, press ^C leave tail.****** tail -f ${resinhome}/log/${svrname}.log fi
假设服务id为report和配置文件名为report.conf,再写一个report.sh:
resinhome="${HOME}/resin" ${resinhome}/bin/newhttpd.sh report $1 $2
$1 及时 start/stop/restart之类的,$2就是需不需要在启动后跟踪log文件,意义不大,用不用随你了。