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

如果用默认的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文件,意义不大,用不用随你了。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值