7.5. 使用 HTTP API 部署应用程序
通过 curl
命令,可以使用 HTTP API 将应用部署到 JBoss EAP。有关使用 HTTP API 的更多信息,请参阅 HTTP API 部分。
7.5.1. 使用 HTTP API 将应用部署到单机服务器
默认情况下,HTTP API 可通过 http://HOST:PORT/management
访问,例如 http://localhost:9990/management
。
部署应用程序
$ curl --digest -L -D - http://HOST:PORT/management --header "Content-Type: application/json" -u USER:PASSWORD -d '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "add", "address" : {"deployment" : "test-application.war"}, "content" : [{"url" : "file:/path/to/test-application.war"}]},{"operation" : "deploy", "address" : {"deployment" : "test-application.war"}}],"json.pretty":1}'
取消部署应用
$ curl --digest -L -D - http://HOST:PORT/management --header "Content-Type: application/json" -u USER:PASSWORD -d '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "undeploy", "address" : {"deployment" : "test-application.war"}},{"operation" : "remove", "address" : {"deployment" : "test-application.war"}}],"json.pretty":1}'
有关以编程方式生成 JSON 请求的更多信息,请参阅红帽知识库文章。
7.5.2. 使用 HTTP API 在受管域中部署应用程序
默认情况下,HTTP API 可通过 http://HOST:PORT/management
访问,例如 http://localhost:9990/management
。
部署应用程序
将部署添加到内容存储库。
$ curl --digest -L -D - http://HOST:PORT/management --header "Content-Type: application/json" -u USER:PASSWORD -d '{"operation" : "add", "address" : {"deployment" : "test-application.war"}, "content" : [{"url" : "file:/path/to/test-application.war"}],"json.pretty":1}'
将部署添加到所需的服务器组。
$ curl --digest -L -D - http://HOST:PORT/management --header "Content-Type: application/json" -u USER:PASSWORD -d '{"operation" : "add", "address" : {"server-group" : "main-server-group","deployment":"test-application.war"},"json.pretty":1}'
将应用部署到服务器组。
$ curl --digest -L -D - http://HOST:PORT/management --header "Content-Type: application/json" -u USER:PASSWORD -d '{"operation" : "deploy", "address" : {"server-group" : "main-server-group","deployment":"test-application.war"},"json.pretty":1}'
取消部署应用
从分配给它的所有服务器组中删除部署。
$ curl --digest -L -D - http://HOST:PORT/management --header "Content-Type: application/json" -u USER:PASSWORD -d '{"operation" : "remove", "address" : {"server-group" : "main-server-group","deployment":"test-application.war"},"json.pretty":1}'
从内容存储库移除部署。
$ curl --digest -L -D - http://HOST:PORT/management --header "Content-Type: application/json" -u USER:PASSWORD -d '{"operation" : "remove", "address" : {"deployment" : "test-application.war"}, "json.pretty":1}'