mirror of https://github.com/aria2/aria2
2010-04-02 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added aria2.shutdown and aria2.forceShutdown XML-RPC method. These methods, as their name implies, shutdown aria2. These methods are useful for Windows because it lacks signal mechanism. * doc/aria2c.1.txt * src/TimedHaltCommand.cc * src/XmlRpcMethodFactory.cc * src/XmlRpcMethodImpl.cc * src/XmlRpcMethodImpl.hpull/1/head
parent
730f7449ae
commit
919255b4db
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2010-04-02 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Added aria2.shutdown and aria2.forceShutdown XML-RPC method.
|
||||||
|
These methods, as their name implies, shutdown aria2. These
|
||||||
|
methods are useful for Windows because it lacks signal mechanism.
|
||||||
|
* doc/aria2c.1.txt
|
||||||
|
* src/TimedHaltCommand.cc
|
||||||
|
* src/XmlRpcMethodFactory.cc
|
||||||
|
* src/XmlRpcMethodImpl.cc
|
||||||
|
* src/XmlRpcMethodImpl.h
|
||||||
|
|
||||||
2010-04-02 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-04-02 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Added forceHalt argument to TimedHaltCommand.
|
Added forceHalt argument to TimedHaltCommand.
|
||||||
|
|
|
@ -2899,6 +2899,14 @@ sessionId
|
||||||
Session ID, which is generated each time when aria2 is invoked\&.
|
Session ID, which is generated each time when aria2 is invoked\&.
|
||||||
.RE
|
.RE
|
||||||
.sp
|
.sp
|
||||||
|
\fBaria2\&.shutdown\fR
|
||||||
|
.sp
|
||||||
|
This method shutdowns aria2\&. This method returns "OK"\&.
|
||||||
|
.sp
|
||||||
|
\fBaria2\&.forceShutdown\fR
|
||||||
|
.sp
|
||||||
|
This method shutdowns aria2\&. This method behaves like \fBaria2\&.shutdown\fR except that any actions which takes time such as contacting BitTorrent tracker are skipped\&. This method returns "OK"\&.
|
||||||
|
.sp
|
||||||
\fBsystem\&.multicall\fR \fImethods\fR
|
\fBsystem\&.multicall\fR \fImethods\fR
|
||||||
.sp
|
.sp
|
||||||
This methods encapsulates multiple method calls in a single request\&. \fImethods\fR is of type array and its element is struct\&. The struct contains two keys: "methodName" and "params"\&. "methodName" is the method name to call and "params" is array containing parameters to the method\&. This method returns array of responses\&. The element of array will either be a one\-item array containing the return value of each method call or struct of fault element if an encapsulated method call fails\&.
|
This methods encapsulates multiple method calls in a single request\&. \fImethods\fR is of type array and its element is struct\&. The struct contains two keys: "methodName" and "params"\&. "methodName" is the method name to call and "params" is array containing parameters to the method\&. This method returns array of responses\&. The element of array will either be a one\-item array containing the return value of each method call or struct of fault element if an encapsulated method call fails\&.
|
||||||
|
|
|
@ -3610,6 +3610,12 @@ sessionId
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
|
<div class="paragraph"><p><strong>aria2.shutdown</strong></p></div>
|
||||||
|
<div class="paragraph"><p>This method shutdowns aria2. This method returns "OK".</p></div>
|
||||||
|
<div class="paragraph"><p><strong>aria2.forceShutdown</strong></p></div>
|
||||||
|
<div class="paragraph"><p>This method shutdowns aria2. This method behaves like <strong>aria2.shutdown</strong>
|
||||||
|
except that any actions which takes time such as contacting BitTorrent
|
||||||
|
tracker are skipped. This method returns "OK".</p></div>
|
||||||
<div class="paragraph"><p><strong>system.multicall</strong> <em>methods</em></p></div>
|
<div class="paragraph"><p><strong>system.multicall</strong> <em>methods</em></p></div>
|
||||||
<div class="paragraph"><p>This methods encapsulates multiple method calls in a single request.
|
<div class="paragraph"><p>This methods encapsulates multiple method calls in a single request.
|
||||||
<em>methods</em> is of type array and its element is struct. The struct
|
<em>methods</em> is of type array and its element is struct. The struct
|
||||||
|
@ -4106,7 +4112,7 @@ files in the program, then also delete it here.</p></div>
|
||||||
<div id="footnotes"><hr /></div>
|
<div id="footnotes"><hr /></div>
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
<div id="footer-text">
|
<div id="footer-text">
|
||||||
Last updated 2010-04-02 23:04:52 JST
|
Last updated 2010-04-02 23:42:11 JST
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -1732,6 +1732,16 @@ sessionId::
|
||||||
|
|
||||||
Session ID, which is generated each time when aria2 is invoked.
|
Session ID, which is generated each time when aria2 is invoked.
|
||||||
|
|
||||||
|
*aria2.shutdown*
|
||||||
|
|
||||||
|
This method shutdowns aria2. This method returns "OK".
|
||||||
|
|
||||||
|
*aria2.forceShutdown*
|
||||||
|
|
||||||
|
This method shutdowns aria2. This method behaves like *aria2.shutdown*
|
||||||
|
except that any actions which takes time such as contacting BitTorrent
|
||||||
|
tracker are skipped. This method returns "OK".
|
||||||
|
|
||||||
*system.multicall* 'methods'
|
*system.multicall* 'methods'
|
||||||
|
|
||||||
This methods encapsulates multiple method calls in a single request.
|
This methods encapsulates multiple method calls in a single request.
|
||||||
|
|
|
@ -61,6 +61,7 @@ void TimedHaltCommand::process()
|
||||||
if(!_e->isHaltRequested()) {
|
if(!_e->isHaltRequested()) {
|
||||||
logger->notice(MSG_TIME_HAS_PASSED, _interval);
|
logger->notice(MSG_TIME_HAS_PASSED, _interval);
|
||||||
if(_forceHalt) {
|
if(_forceHalt) {
|
||||||
|
logger->notice("This is emergency shutdown.");
|
||||||
_e->requestForceHalt();
|
_e->requestForceHalt();
|
||||||
} else {
|
} else {
|
||||||
_e->requestHalt();
|
_e->requestHalt();
|
||||||
|
|
|
@ -97,6 +97,10 @@ XmlRpcMethodFactory::create(const std::string& methodName)
|
||||||
return SharedHandle<XmlRpcMethod>(new GetVersionXmlRpcMethod());
|
return SharedHandle<XmlRpcMethod>(new GetVersionXmlRpcMethod());
|
||||||
} else if(methodName == GetSessionInfoXmlRpcMethod::getMethodName()) {
|
} else if(methodName == GetSessionInfoXmlRpcMethod::getMethodName()) {
|
||||||
return SharedHandle<XmlRpcMethod>(new GetSessionInfoXmlRpcMethod());
|
return SharedHandle<XmlRpcMethod>(new GetSessionInfoXmlRpcMethod());
|
||||||
|
} else if(methodName == ShutdownXmlRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<XmlRpcMethod>(new ShutdownXmlRpcMethod());
|
||||||
|
} else if(methodName == ForceShutdownXmlRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<XmlRpcMethod>(new ForceShutdownXmlRpcMethod());
|
||||||
} else if(methodName == SystemMulticallXmlRpcMethod::getMethodName()) {
|
} else if(methodName == SystemMulticallXmlRpcMethod::getMethodName()) {
|
||||||
return SharedHandle<XmlRpcMethod>(new SystemMulticallXmlRpcMethod());
|
return SharedHandle<XmlRpcMethod>(new SystemMulticallXmlRpcMethod());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
#include "LogFactory.h"
|
||||||
#include "BDE.h"
|
#include "BDE.h"
|
||||||
#include "DlAbortEx.h"
|
#include "DlAbortEx.h"
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
|
@ -62,6 +63,7 @@
|
||||||
#include "XmlRpcMethodFactory.h"
|
#include "XmlRpcMethodFactory.h"
|
||||||
#include "XmlRpcResponse.h"
|
#include "XmlRpcResponse.h"
|
||||||
#include "SegmentMan.h"
|
#include "SegmentMan.h"
|
||||||
|
#include "TimedHaltCommand.h"
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
# include "bittorrent_helper.h"
|
# include "bittorrent_helper.h"
|
||||||
# include "BtRegistry.h"
|
# include "BtRegistry.h"
|
||||||
|
@ -1008,6 +1010,27 @@ BDE ChangeUriXmlRpcMethod::process
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BDE goingShutdown
|
||||||
|
(const XmlRpcRequest& req, DownloadEngine* e, bool forceHalt)
|
||||||
|
{
|
||||||
|
// Schedule shutdown after 3seconds to give time to client to
|
||||||
|
// receive XML-RPC response.
|
||||||
|
e->addRoutineCommand(new TimedHaltCommand(e->newCUID(), e, 3, forceHalt));
|
||||||
|
LogFactory::getInstance()->info("Scheduled shutdown in 3 seconds.");
|
||||||
|
return BDE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
BDE ShutdownXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
|
{
|
||||||
|
return goingShutdown(req, e, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
BDE ForceShutdownXmlRpcMethod::process
|
||||||
|
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
|
{
|
||||||
|
return goingShutdown(req, e, true);
|
||||||
|
}
|
||||||
|
|
||||||
BDE SystemMulticallXmlRpcMethod::process
|
BDE SystemMulticallXmlRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -385,6 +385,28 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ShutdownXmlRpcMethod:public XmlRpcMethod {
|
||||||
|
protected:
|
||||||
|
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||||
|
public:
|
||||||
|
static const std::string& getMethodName()
|
||||||
|
{
|
||||||
|
static std::string methodName = "aria2.shutdown";
|
||||||
|
return methodName;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ForceShutdownXmlRpcMethod:public XmlRpcMethod {
|
||||||
|
protected:
|
||||||
|
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||||
|
public:
|
||||||
|
static const std::string& getMethodName()
|
||||||
|
{
|
||||||
|
static std::string methodName = "aria2.forceShutdown";
|
||||||
|
return methodName;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class SystemMulticallXmlRpcMethod:public XmlRpcMethod {
|
class SystemMulticallXmlRpcMethod:public XmlRpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||||
|
|
Loading…
Reference in New Issue