resin在一台机器上启动多个resin服务

来源:互联网 发布:数据分析 培训 广州 编辑:程序博客网 时间:2024/06/05 07:16

如果用默认的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"/>。

然后启动时指定配置文件:

Xml代码
${resinhome}/bin/httpd.sh -conf ${resinhome}/conf/${svrname}.conf -server $svrname 

${resinhome}/bin/httpd.sh -conf ${resinhome}/conf/${svrname}.conf -server $svrnamesvrname是服务id和配置文件的名称(假设是相同的)。

为了区别不同服务的日志,还要改一个地方:

Xml代码
<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'/> 

<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:

Xml代码
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 

 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:

Xml代码
resinhome="${HOME}/resin" 
${resinhome}/bin/newhttpd.sh report $1 $2 

resinhome="${HOME}/resin"
${resinhome}/bin/newhttpd.sh report $1 $2  $1 及时 start/stop/restart之类的,$2就是需不需要在启动后跟踪log文件,意义不大,用不用随你了。

 

原创粉丝点击