今天無(wú)意中發(fā)現(xiàn)tomcat5.5的管理功能已經(jīng)非常強(qiáng)大了,只要你配置好了tomcat-user.xml.
主要是增加一個(gè)具有系統(tǒng)管理權(quán)限的用戶,比如增加一個(gè)用戶名和密碼都是suxiaoyong的用戶,只需要在在最后一行增加
代碼 | <user username="suxiaoyong" password="suxiaoyong" roles="admin,manager"/> |
其他的用戶都可以刪掉了
然后,我們可以進(jìn)入http://localhost:8080/manager/status 來(lái)查看服務(wù)器的各種狀態(tài).
也可以通過(guò)url來(lái)直接對(duì)應(yīng)用進(jìn)行監(jiān)控
命令格式
代碼 | http://{ host }:{ port }/manager/{ command }?{ parameters } |
部署一個(gè)應(yīng)用
列出已經(jīng)部署的應(yīng)用
代碼 | http://localhost:8080/manager/list |
重新加載一個(gè)應(yīng)用
比如你更新了class或者lib的話,需要重新加載系統(tǒng)
代碼 | http://localhost:8080/manager/reload?path=/examples |
查看jvm和系統(tǒng)信息
代碼 | http://localhost:8080/manager/serverinfo |
查看可用的安全角色
代碼 | http://localhost:8080/manager/roles |
查看某個(gè)應(yīng)用默認(rèn)的session超時(shí)時(shí)間和當(dāng)前活躍的session數(shù)
代碼 | http://localhost:8080/manager/sessions?path=/examples |
啟動(dòng)一個(gè)應(yīng)用
比如有時(shí)候重新啟動(dòng)數(shù)據(jù)庫(kù)后可能需要重新啟動(dòng)應(yīng)用
代碼 | http://localhost:8080/manager/start?path=/examples |
關(guān)閉一個(gè)應(yīng)用
關(guān)閉后,任何發(fā)往該應(yīng)用的請(qǐng)求都將轉(zhuǎn)向404錯(cuò)誤的頁(yè)面
代碼 | http://localhost:8080/manager/stop?path=/examples |
? undeploy
慎用,將刪除應(yīng)用的目錄及其war文件
ant腳本,更多的詳見(jiàn)tomcat5.5的文檔
代碼 | <project name="My Application" default="compile" basedir=".">
?<!-- Configure the directory into which the web application is built --> ?<property name="build" ? ?value="${ basedir }/build"/>
?<!-- Configure the context path for this application --> ?<property name="path" ? ? value="/myapp"/>
?<!-- Configure properties to access the Manager application --> ?<property name="url" ? ? ?value="http://localhost:8080/manager"/> ?<property name="username" value="myusername"/> ?<property name="password" value="mypassword"/>
?<!-- Configure the custom Ant tasks for the Manager application --> ?<taskdef name="deploy" ? ?classname="org.apache.catalina.ant.DeployTask"/> ?<taskdef name="list" ? ? ?classname="org.apache.catalina.ant.ListTask"/> ?<taskdef name="reload" ? ?classname="org.apache.catalina.ant.ReloadTask"/> ?<taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask"/> ?<taskdef name="roles" ? ? classname="org.apache.catalina.ant.RolesTask"/> ?<taskdef name="start" ? ? classname="org.apache.catalina.ant.StartTask"/> ?<taskdef name="stop" ? ? ?classname="org.apache.catalina.ant.StopTask"/> ?<taskdef name="undeploy" ?classname="org.apache.catalina.ant.UndeployTask"/>
?<!-- Executable Targets --> ?<target name="compile" description="Compile web application"> ? ?<!-- ... construct web application in ${ build } subdirectory, and ? ? ? ? ? ?generated a ${ path }.war ... --> ?</target>
?<target name="deploy" description="Install web application" ? ? ? ? ?depends="compile"> ? ?<deploy url="${ url }" username="${ username }" password="${ password }" ? ? ? ? ? ?path="${ path }" war="${ build }${ path }.war"/> ?</target>
?<target name="reload" description="Reload web application" ? ? ? ? ?depends="compile"> ? ?<reload ?url="${ url }" username="${ username }" password="${ password }" ? ? ? ? ? ?path="${ path }"/> ?</target>
?<target name="undeploy" description="Remove web application"> ? ?<undeploy url="${ url }" username="${ username }" password="${ password }" ? ? ? ? ? ?path="${ path }"/> ?</target>
</project> |
|
|
|
|
| 日 | 一 | 二 | 三 | 四 | 五 | 六 |
---|
29 | 30 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|
導(dǎo)航
統(tǒng)計(jì)
- 隨筆: 32
- 文章: 427
- 評(píng)論: 144
- 引用: 0
常用鏈接
留言簿(5)
隨筆檔案
文章分類
文章檔案
java
工具
朋友
搜索
積分與排名
最新評(píng)論

閱讀排行榜
評(píng)論排行榜
|
|