Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
623 views
in Technique[技术] by (71.8m points)

curl - Tomcat manager remote deploy script

I'm writing a shell script to auto deploy/undeploy using the tomcat manager.

Following the instructions on http://tomcat.apache.org/tomcat-6.0-doc/manager-howto.html#Deploy_A_New_Application_Remotely, I use curl for my deployment

curl --anyauth -u username:pwd -d path=/something -d war=file:target/someWar.war https://someurl.com/manager/deploy

And I get the response saying HTTP method POST is not supported by this URL.

So I change my curl to be a get using -G

curl --anyauth -u username:pwd -G -d path=/something -d war=file:target/someWar.war https://someurl.com/manager/deploy

I get a response of FAIL - Failed to deploy application at context path /something and it seems to be looking for the file locally on the server instead of my machine. There are pluings which do remote deploy without having to scp the file over so I'm wondering what I'm missing.

I'm currently out of ideas (I don't see any other option on the tomcat manager configuration page).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Providing an update to this question.

Tomcat 7 has changed it's manager API.

Please refer to: Manager commands

Following new URL pattern :

http://{host}:{port}/manager/text/{command}?{parameters}

Example

curl -T "myapp.war" "http://manager:manager@localhost:8080/manager/text/deploy?path=/myapp&update=true"

Security

Keep in mind the server must be able to accept your remote IP. This is a sample configuration:

<Context privileged="true" antiResourceLocking="false"
         docBase="${catalina.home}/webapps/manager">
  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127.0.0.1" />
</Context>

This is an optional setting and isn't required but having Cross domain role and proper manager credentials is a must.

Tomcat 8 - the same rules apply as Tomcat 7. Same commands.

Here is a full documentation:

http://tomcat.apache.org/tomcat-8.0-doc/manager-howto.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...