@@ -161,9 +161,12 @@ public FullHttpResponse openUrl(Channel channel, FullHttpRequest request) throws
161161 public FullHttpResponse doUpdate (Channel channel , FullHttpRequest request ) throws Exception {
162162 Map <String , Object > map = getJSONParams (request );
163163 String url = (String ) map .get ("path" );
164- String path = PathUtil .ROOT_PATH + File .separator + "proxyee-down-main.jar.bak " ;
164+ String path = PathUtil .ROOT_PATH + File .separator + "proxyee-down-main.jar.tmp " ;
165165 try {
166- AppUtil .download (url , PathUtil .ROOT_PATH + File .separator + "proxyee-down-main.jar.bak" );
166+ AppUtil .download (url , path );
167+ File updateTmpJar = new File (path );
168+ File updateBakJar = new File (updateTmpJar .getParent () + File .separator + "proxyee-down-main.jar.bak" );
169+ updateTmpJar .renameTo (updateBakJar );
167170 } catch (Exception e ) {
168171 File file = new File (path );
169172 if (file .exists ()) {
@@ -174,9 +177,15 @@ public FullHttpResponse doUpdate(Channel channel, FullHttpRequest request) throw
174177 return new DefaultFullHttpResponse (HttpVersion .HTTP_1_1 , HttpResponseStatus .OK );
175178 }
176179
180+ @ RequestMapping ("doReplace" )
181+ public FullHttpResponse doReplace (Channel channel , FullHttpRequest request ) throws Exception {
182+ System .out .println ("proxyee-down-restart" );
183+ return new DefaultFullHttpResponse (HttpVersion .HTTP_1_1 , HttpResponseStatus .OK );
184+ }
185+
177186 @ RequestMapping ("doRestart" )
178187 public FullHttpResponse doRestart (Channel channel , FullHttpRequest request ) throws Exception {
179- System .out .println ("proxyee-down-exit " );
188+ System .out .println ("proxyee-down-restart " );
180189 return new DefaultFullHttpResponse (HttpVersion .HTTP_1_1 , HttpResponseStatus .OK );
181190 }
182191
0 commit comments