938 lines
28 KiB
HTML
938 lines
28 KiB
HTML
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>
|
||
Class: Rex::ServiceManager
|
||
|
||
— Documentation by YARD 0.9.37
|
||
|
||
</title>
|
||
|
||
<link rel="stylesheet" href="../css/style.css" type="text/css" />
|
||
|
||
<link rel="stylesheet" href="../css/common.css" type="text/css" />
|
||
|
||
<script type="text/javascript">
|
||
pathId = "Rex::ServiceManager";
|
||
relpath = '../';
|
||
</script>
|
||
|
||
|
||
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
||
|
||
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
||
|
||
|
||
</head>
|
||
<body>
|
||
<div class="nav_wrap">
|
||
<iframe id="nav" src="../class_list.html?1"></iframe>
|
||
<div id="resizer"></div>
|
||
</div>
|
||
|
||
<div id="main" tabindex="-1">
|
||
<div id="header">
|
||
<div id="menu">
|
||
|
||
<a href="../_index.html">Index (S)</a> »
|
||
<span class='title'><span class='object_link'><a href="../Rex.html" title="Rex (module)">Rex</a></span></span>
|
||
»
|
||
<span class="title">ServiceManager</span>
|
||
|
||
</div>
|
||
|
||
<div id="search">
|
||
|
||
<a class="full_list_link" id="class_list_link"
|
||
href="../class_list.html">
|
||
|
||
<svg width="24" height="24">
|
||
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
||
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
||
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
||
</svg>
|
||
</a>
|
||
|
||
</div>
|
||
<div class="clear"></div>
|
||
</div>
|
||
|
||
<div id="content"><h1>Class: Rex::ServiceManager
|
||
|
||
|
||
|
||
</h1>
|
||
<div class="box_info">
|
||
|
||
<dl>
|
||
<dt>Inherits:</dt>
|
||
<dd>
|
||
<span class="inheritName">Hash</span>
|
||
|
||
<ul class="fullTree">
|
||
<li>Object</li>
|
||
|
||
<li class="next">Hash</li>
|
||
|
||
<li class="next">Rex::ServiceManager</li>
|
||
|
||
</ul>
|
||
<a href="#" class="inheritanceTree">show all</a>
|
||
|
||
</dd>
|
||
</dl>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<dl>
|
||
<dt>Includes:</dt>
|
||
<dd>Singleton</dd>
|
||
</dl>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<dl>
|
||
<dt>Defined in:</dt>
|
||
<dd>lib/rex/service_manager.rb</dd>
|
||
</dl>
|
||
|
||
</div>
|
||
|
||
<h2>Overview</h2><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>This class manages service allocation and interaction. This class can be used to start HTTP servers and manage them and all that stuff. Yup.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h2>
|
||
Class Method Summary
|
||
<small><a href="#" class="summary_toggle">collapse</a></small>
|
||
</h2>
|
||
|
||
<ul class="summary">
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#start-class_method" title="start (class method)">.<strong>start</strong>(klass, *args, **kwargs) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Calls the instance method to start a service.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#stop-class_method" title="stop (class method)">.<strong>stop</strong>(klass, *args, **kwargs) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Calls the instance method to stop a service.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#stop_by_alias-class_method" title="stop_by_alias (class method)">.<strong>stop_by_alias</strong>(als) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Stop a service using the alias that’s associated with it.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#stop_service-class_method" title="stop_service (class method)">.<strong>stop_service</strong>(service) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Stop the supplied service instance.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
</ul>
|
||
|
||
<h2>
|
||
Instance Method Summary
|
||
<small><a href="#" class="summary_toggle">collapse</a></small>
|
||
</h2>
|
||
|
||
<ul class="summary">
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#each-instance_method" title="#each (instance method)">#<strong>each</strong>(&block) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Overrides the builtin ‘each’ operator to avoid the following exception on Ruby 1.9.2+ “can’t add a new key into hash during iteration”.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="protected ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#hardcore_alias-instance_method" title="#hardcore_alias (instance method)">#<strong>hardcore_alias</strong>(klass, *args) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
<span class="note title protected">protected</span>
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Returns the alias for a given service instance.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#start-instance_method" title="#start (instance method)">#<strong>start</strong>(klass, *args, **kwargs) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Starts a service and assigns it a unique name in the service hash.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#stop-instance_method" title="#stop (instance method)">#<strong>stop</strong>(klass, *args, **kwargs) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Stop a service using a given klass and arguments.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#stop_by_alias-instance_method" title="#stop_by_alias (instance method)">#<strong>stop_by_alias</strong>(als) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Stops a service using the provided alias.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#stop_service-instance_method" title="#stop_service (instance method)">#<strong>stop_service</strong>(inst) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Stops a service instance.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
</ul>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<div id="class_method_details" class="method_details_list">
|
||
<h2>Class Method Details</h2>
|
||
|
||
|
||
<div class="method_details first">
|
||
<h3 class="signature first" id="start-class_method">
|
||
|
||
.<strong>start</strong>(klass, *args, **kwargs) ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Calls the instance method to start a service.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
23
|
||
24
|
||
25</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/rex/service_manager.rb', line 23</span>
|
||
|
||
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_start'>start</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
|
||
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_start'>start</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="stop-class_method">
|
||
|
||
.<strong>stop</strong>(klass, *args, **kwargs) ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Calls the instance method to stop a service.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
30
|
||
31
|
||
32</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/rex/service_manager.rb', line 30</span>
|
||
|
||
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
|
||
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="stop_by_alias-class_method">
|
||
|
||
.<strong>stop_by_alias</strong>(als) ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Stop a service using the alias that’s associated with it.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
37
|
||
38
|
||
39</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/rex/service_manager.rb', line 37</span>
|
||
|
||
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_stop_by_alias'>stop_by_alias</span><span class='lparen'>(</span><span class='id identifier rubyid_als'>als</span><span class='rparen'>)</span>
|
||
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_stop_by_alias'>stop_by_alias</span><span class='lparen'>(</span><span class='id identifier rubyid_als'>als</span><span class='rparen'>)</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="stop_service-class_method">
|
||
|
||
.<strong>stop_service</strong>(service) ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Stop the supplied service instance.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
44
|
||
45
|
||
46</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/rex/service_manager.rb', line 44</span>
|
||
|
||
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_stop_service'>stop_service</span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='rparen'>)</span>
|
||
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_stop_service'>stop_service</span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='rparen'>)</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div id="instance_method_details" class="method_details_list">
|
||
<h2>Instance Method Details</h2>
|
||
|
||
|
||
<div class="method_details first">
|
||
<h3 class="signature first" id="each-instance_method">
|
||
|
||
#<strong>each</strong>(&block) ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Overrides the builtin ‘each’ operator to avoid the following exception on Ruby 1.9.2+</p>
|
||
|
||
<pre class="code ruby"><code class="ruby"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>can't add a new key into hash during iteration</span><span class='tstring_end'>"</span></span>
|
||
</code></pre>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
134
|
||
135
|
||
136
|
||
137
|
||
138
|
||
139
|
||
140</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/rex/service_manager.rb', line 134</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_list'>list</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
||
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_sort'>sort</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_sidx'>sidx</span><span class='op'>|</span>
|
||
<span class='id identifier rubyid_list'>list</span> <span class='op'><<</span> <span class='lbracket'>[</span><span class='id identifier rubyid_sidx'>sidx</span><span class='comma'>,</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_sidx'>sidx</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
|
||
<span class='kw'>end</span>
|
||
<span class='id identifier rubyid_list'>list</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="hardcore_alias-instance_method">
|
||
|
||
#<strong>hardcore_alias</strong>(klass, *args) ⇒ <tt>Object</tt> <span class="extras">(protected)</span>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Returns the alias for a given service instance.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
147
|
||
148
|
||
149</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/rex/service_manager.rb', line 147</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid_hardcore_alias'>hardcore_alias</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
||
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>__</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_klass'>klass</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_args'>args</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="start-instance_method">
|
||
|
||
#<strong>start</strong>(klass, *args, **kwargs) ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Starts a service and assigns it a unique name in the service hash.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
51
|
||
52
|
||
53
|
||
54
|
||
55
|
||
56
|
||
57
|
||
58
|
||
59
|
||
60
|
||
61
|
||
62
|
||
63
|
||
64
|
||
65
|
||
66
|
||
67
|
||
68
|
||
69
|
||
70
|
||
71
|
||
72
|
||
73
|
||
74
|
||
75
|
||
76
|
||
77
|
||
78
|
||
79
|
||
80
|
||
81
|
||
82
|
||
83
|
||
84
|
||
85
|
||
86
|
||
87
|
||
88
|
||
89</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/rex/service_manager.rb', line 51</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid_start'>start</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
|
||
<span class='comment'># Get the hardcore alias.
|
||
</span> <span class='id identifier rubyid_hals'>hals</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_klass'>klass</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='op'>+</span> <span class='id identifier rubyid_klass'>klass</span><span class='period'>.</span><span class='id identifier rubyid_hardcore_alias'>hardcore_alias</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
|
||
|
||
<span class='comment'># Has a service already been constructed for this guy? If so, increment
|
||
</span> <span class='comment'># its reference count like it aint no thang.
|
||
</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_inst'>inst</span> <span class='op'>=</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_hals'>hals</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_inst'>inst</span><span class='period'>.</span><span class='id identifier rubyid_ref'>ref</span>
|
||
<span class='kw'>return</span> <span class='id identifier rubyid_inst'>inst</span>
|
||
<span class='kw'>end</span>
|
||
|
||
<span class='id identifier rubyid_inst'>inst</span> <span class='op'>=</span> <span class='id identifier rubyid_klass'>klass</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_als'>als</span> <span class='op'>=</span> <span class='id identifier rubyid_inst'>inst</span><span class='period'>.</span><span class='id identifier rubyid_alias'>alias</span>
|
||
|
||
<span class='comment'># Find an alias that isn't taken.
|
||
</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_als'>als</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_cnt'>cnt</span> <span class='op'>=</span> <span class='int'>1</span>
|
||
<span class='id identifier rubyid_cnt'>cnt</span> <span class='op'>+=</span> <span class='int'>1</span> <span class='kw'>while</span> <span class='lparen'>(</span><span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_als'>als</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cnt'>cnt</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_als'>als</span> <span class='op'>=</span> <span class='id identifier rubyid_inst'>inst</span><span class='period'>.</span><span class='id identifier rubyid_alias'>alias</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cnt'>cnt</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
||
<span class='kw'>end</span>
|
||
|
||
<span class='comment'># Extend the instance as a service.
|
||
</span> <span class='id identifier rubyid_inst'>inst</span><span class='period'>.</span><span class='id identifier rubyid_extend'>extend</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../Rex.html" title="Rex (module)">Rex</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Service.html" title="Rex::Service (module)">Service</a></span></span><span class='rparen'>)</span>
|
||
|
||
<span class='comment'># Re-aliases the instance.
|
||
</span> <span class='id identifier rubyid_inst'>inst</span><span class='period'>.</span><span class='id identifier rubyid_alias'>alias</span> <span class='op'>=</span> <span class='id identifier rubyid_als'>als</span>
|
||
|
||
<span class='comment'># Fire up the engines. If an error occurs an exception will be
|
||
</span> <span class='comment'># raised.
|
||
</span> <span class='id identifier rubyid_inst'>inst</span><span class='period'>.</span><span class='id identifier rubyid_start'>start</span>
|
||
|
||
<span class='comment'># Alias associate and initialize reference counting
|
||
</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_als'>als</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_hals'>hals</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_inst'>inst</span><span class='period'>.</span><span class='id identifier rubyid_refinit'>refinit</span>
|
||
|
||
<span class='comment'># Pass the caller a reference
|
||
</span> <span class='id identifier rubyid_inst'>inst</span><span class='period'>.</span><span class='id identifier rubyid_ref'>ref</span>
|
||
|
||
<span class='id identifier rubyid_inst'>inst</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="stop-instance_method">
|
||
|
||
#<strong>stop</strong>(klass, *args, **kwargs) ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Stop a service using a given klass and arguments. These should mirror what was originally passed to start exactly. If the reference count of the service drops to zero the service will be destroyed.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
96
|
||
97
|
||
98</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/rex/service_manager.rb', line 96</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid_stop'>stop</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_stop_service'>stop_service</span><span class='lparen'>(</span><span class='id identifier rubyid_hals'>hals</span><span class='lbracket'>[</span><span class='id identifier rubyid_hardcore_alias'>hardcore_alias</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="stop_by_alias-instance_method">
|
||
|
||
#<strong>stop_by_alias</strong>(als) ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Stops a service using the provided alias.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
103
|
||
104
|
||
105</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/rex/service_manager.rb', line 103</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid_stop_by_alias'>stop_by_alias</span><span class='lparen'>(</span><span class='id identifier rubyid_als'>als</span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_stop_service'>stop_service</span><span class='lparen'>(</span><span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_als'>als</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="stop_service-instance_method">
|
||
|
||
#<strong>stop_service</strong>(inst) ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Stops a service instance.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
110
|
||
111
|
||
112
|
||
113
|
||
114
|
||
115
|
||
116
|
||
117
|
||
118
|
||
119
|
||
120
|
||
121
|
||
122
|
||
123
|
||
124
|
||
125
|
||
126
|
||
127
|
||
128</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/rex/service_manager.rb', line 110</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid_stop_service'>stop_service</span><span class='lparen'>(</span><span class='id identifier rubyid_inst'>inst</span><span class='rparen'>)</span>
|
||
<span class='comment'># Stop the service and be done wif it, but only if the number of
|
||
</span> <span class='comment'># references has dropped to zero
|
||
</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_inst'>inst</span><span class='rparen'>)</span>
|
||
<span class='comment'># Since the instance may have multiple aliases, scan through
|
||
</span> <span class='comment'># all the pairs for matching stuff.
|
||
</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_cals'>cals</span><span class='comma'>,</span> <span class='id identifier rubyid_cinst'>cinst</span><span class='op'>|</span>
|
||
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_cals'>cals</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_inst'>inst</span> <span class='op'>==</span> <span class='id identifier rubyid_cinst'>cinst</span><span class='rparen'>)</span>
|
||
<span class='rbrace'>}</span>
|
||
|
||
<span class='comment'># Lose the list-held reference to the instance
|
||
</span> <span class='id identifier rubyid_inst'>inst</span><span class='period'>.</span><span class='id identifier rubyid_deref'>deref</span>
|
||
|
||
<span class='kw'>return</span> <span class='kw'>true</span>
|
||
<span class='kw'>end</span>
|
||
|
||
<span class='comment'># Return false if the service isn't there
|
||
</span> <span class='kw'>return</span> <span class='kw'>false</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div id="footer">
|
||
Generated on Fri May 8 17:04:07 2026 by
|
||
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
||
0.9.37 (ruby-3.1.5).
|
||
</div>
|
||
|
||
</div>
|
||
</body>
|
||
</html> |