Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[dist] Remove outdated docco docs

  • Loading branch information...
commit c1f1e6fac44a09aed052451964f67b0727c53296 1 parent b5ce548
@indexzero indexzero authored
View
194 docs/docco.css
@@ -1,194 +0,0 @@
-/*--------------------- Layout and Typography ----------------------------*/
-body {
- font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
- font-size: 15px;
- line-height: 22px;
- color: #252519;
- margin: 0; padding: 0;
-}
-a {
- color: #261a3b;
-}
- a:visited {
- color: #261a3b;
- }
-p {
- margin: 0 0 15px 0;
-}
-h4, h5, h6 {
- color: #333;
- margin: 6px 0 6px 0;
- font-size: 13px;
-}
- h2, h3 {
- margin-bottom: 0;
- color: #000;
- }
- h1 {
- margin-top: 40px;
- margin-bottom: 15px;
- color: #000;
- }
-#container {
- position: relative;
-}
-#background {
- position: fixed;
- top: 0; left: 525px; right: 0; bottom: 0;
- background: #f5f5ff;
- border-left: 1px solid #e5e5ee;
- z-index: -1;
-}
-#jump_to, #jump_page {
- background: white;
- -webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
- -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
- font: 10px Arial;
- text-transform: uppercase;
- cursor: pointer;
- text-align: right;
-}
-#jump_to, #jump_wrapper {
- position: fixed;
- right: 0; top: 0;
- padding: 5px 10px;
-}
- #jump_wrapper {
- padding: 0;
- display: none;
- }
- #jump_to:hover #jump_wrapper {
- display: block;
- }
- #jump_page {
- padding: 5px 0 3px;
- margin: 0 0 25px 25px;
- }
- #jump_page .source {
- display: block;
- padding: 5px 10px;
- text-decoration: none;
- border-top: 1px solid #eee;
- }
- #jump_page .source:hover {
- background: #f5f5ff;
- }
- #jump_page .source:first-child {
- }
-table td {
- border: 0;
- outline: 0;
-}
- td.docs, th.docs {
- max-width: 450px;
- min-width: 450px;
- min-height: 5px;
- padding: 10px 25px 1px 50px;
- overflow-x: hidden;
- vertical-align: top;
- text-align: left;
- }
- .docs pre {
- margin: 15px 0 15px;
- padding-left: 15px;
- }
- .docs p tt, .docs p code {
- background: #f8f8ff;
- border: 1px solid #dedede;
- font-size: 12px;
- padding: 0 0.2em;
- }
- .pilwrap {
- position: relative;
- }
- .pilcrow {
- font: 12px Arial;
- text-decoration: none;
- color: #454545;
- position: absolute;
- top: 3px; left: -20px;
- padding: 1px 2px;
- opacity: 0;
- -webkit-transition: opacity 0.2s linear;
- }
- td.docs:hover .pilcrow {
- opacity: 1;
- }
- td.code, th.code {
- padding: 14px 15px 16px 25px;
- width: 100%;
- vertical-align: top;
- background: #f5f5ff;
- border-left: 1px solid #e5e5ee;
- }
- pre, tt, code {
- font-size: 12px; line-height: 18px;
- font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
- margin: 0; padding: 0;
- }
-
-
-/*---------------------- Syntax Highlighting -----------------------------*/
-td.linenos { background-color: #f0f0f0; padding-right: 10px; }
-span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
-body .hll { background-color: #ffffcc }
-body .c { color: #408080; font-style: italic } /* Comment */
-body .err { border: 1px solid #FF0000 } /* Error */
-body .k { color: #954121 } /* Keyword */
-body .o { color: #666666 } /* Operator */
-body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
-body .cp { color: #BC7A00 } /* Comment.Preproc */
-body .c1 { color: #408080; font-style: italic } /* Comment.Single */
-body .cs { color: #408080; font-style: italic } /* Comment.Special */
-body .gd { color: #A00000 } /* Generic.Deleted */
-body .ge { font-style: italic } /* Generic.Emph */
-body .gr { color: #FF0000 } /* Generic.Error */
-body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
-body .gi { color: #00A000 } /* Generic.Inserted */
-body .go { color: #808080 } /* Generic.Output */
-body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
-body .gs { font-weight: bold } /* Generic.Strong */
-body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
-body .gt { color: #0040D0 } /* Generic.Traceback */
-body .kc { color: #954121 } /* Keyword.Constant */
-body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */
-body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */
-body .kp { color: #954121 } /* Keyword.Pseudo */
-body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */
-body .kt { color: #B00040 } /* Keyword.Type */
-body .m { color: #666666 } /* Literal.Number */
-body .s { color: #219161 } /* Literal.String */
-body .na { color: #7D9029 } /* Name.Attribute */
-body .nb { color: #954121 } /* Name.Builtin */
-body .nc { color: #0000FF; font-weight: bold } /* Name.Class */
-body .no { color: #880000 } /* Name.Constant */
-body .nd { color: #AA22FF } /* Name.Decorator */
-body .ni { color: #999999; font-weight: bold } /* Name.Entity */
-body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
-body .nf { color: #0000FF } /* Name.Function */
-body .nl { color: #A0A000 } /* Name.Label */
-body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
-body .nt { color: #954121; font-weight: bold } /* Name.Tag */
-body .nv { color: #19469D } /* Name.Variable */
-body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
-body .w { color: #bbbbbb } /* Text.Whitespace */
-body .mf { color: #666666 } /* Literal.Number.Float */
-body .mh { color: #666666 } /* Literal.Number.Hex */
-body .mi { color: #666666 } /* Literal.Number.Integer */
-body .mo { color: #666666 } /* Literal.Number.Oct */
-body .sb { color: #219161 } /* Literal.String.Backtick */
-body .sc { color: #219161 } /* Literal.String.Char */
-body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
-body .s2 { color: #219161 } /* Literal.String.Double */
-body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
-body .sh { color: #219161 } /* Literal.String.Heredoc */
-body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
-body .sx { color: #954121 } /* Literal.String.Other */
-body .sr { color: #BB6688 } /* Literal.String.Regex */
-body .s1 { color: #219161 } /* Literal.String.Single */
-body .ss { color: #19469D } /* Literal.String.Symbol */
-body .bp { color: #954121 } /* Name.Builtin.Pseudo */
-body .vc { color: #19469D } /* Name.Variable.Class */
-body .vg { color: #19469D } /* Name.Variable.Global */
-body .vi { color: #19469D } /* Name.Variable.Instance */
-body .il { color: #666666 } /* Literal.Number.Integer.Long */
View
608 docs/forever.html
0 additions, 608 deletions not shown
View
289 docs/forever/cli.html
@@ -1,289 +0,0 @@
-<!DOCTYPE html> <html> <head> <title>cli.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//forever/cli.html"> forever/cli.html </a> <a class="source" href="..//forever/monitor.html"> forever/monitor.html </a> <a class="source" href="..//forever.html"> forever.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> cli.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
-<span class="cm"> * cli.js: Handlers for the forever CLI commands.</span>
-<span class="cm"> *</span>
-<span class="cm"> * (C) 2010 Charlie Robbins</span>
-<span class="cm"> * MIT LICENCE</span>
-<span class="cm"> *</span>
-<span class="cm"> */</span>
-
-<span class="kd">var</span> <span class="nx">sys</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;sys&#39;</span><span class="p">),</span>
- <span class="nx">path</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;path&#39;</span><span class="p">),</span>
- <span class="nx">cliff</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;cliff&#39;</span><span class="p">),</span>
- <span class="nx">forever</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;../forever&#39;</span><span class="p">);</span>
-
-<span class="kd">var</span> <span class="nx">cli</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">;</span>
-
-<span class="kd">var</span> <span class="nx">reserved</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;root&#39;</span><span class="p">,</span> <span class="s1">&#39;pidPath&#39;</span><span class="p">];</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>function exec (action, file, options)</h3>
-
-<h4>@action {string} CLI action to execute</h4>
-
-<h4>@file {string} Location of the target forever script or process.</h4>
-
-<h4>@options {Object} Options to pass to forever for the <code>action</code>.</h4>
-
-<p>Executes the <code>action</code> in forever with the specified <code>file</code> and <code>options</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">exec</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">action</span><span class="p">,</span> <span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">display</span> <span class="o">=</span> <span class="nb">Array</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">action</span><span class="p">)</span> <span class="o">?</span> <span class="nx">action</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">)</span> <span class="o">:</span> <span class="nx">action</span><span class="p">;</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="nx">action</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Running action: &#39;</span> <span class="o">+</span> <span class="nx">display</span><span class="p">.</span><span class="nx">yellow</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="nx">action</span> <span class="o">===</span> <span class="s1">&#39;cleanlogs&#39;</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">silly</span><span class="p">(</span><span class="s1">&#39;Tidying &#39;</span> <span class="o">+</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;root&#39;</span><span class="p">));</span>
- <span class="kd">var</span> <span class="nx">tidy</span> <span class="o">=</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">cleanUp</span><span class="p">(</span><span class="nx">action</span> <span class="o">===</span> <span class="s1">&#39;cleanlogs&#39;</span><span class="p">);</span>
- <span class="nx">tidy</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;cleanUp&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">silly</span><span class="p">(</span><span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;root&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; tidied.&#39;</span><span class="p">);</span>
- <span class="p">});</span>
- <span class="k">return</span><span class="p">;</span>
- <span class="p">}</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="nx">file</span> <span class="o">&amp;&amp;</span> <span class="nx">action</span> <span class="o">===</span> <span class="s1">&#39;start&#39;</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Forever processing file: &#39;</span> <span class="o">+</span> <span class="nx">file</span><span class="p">.</span><span class="nx">grey</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">command</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Forever using command: &#39;</span> <span class="o">+</span> <span class="nx">options</span><span class="p">.</span><span class="nx">command</span><span class="p">.</span><span class="nx">grey</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="nx">options</span> <span class="o">&amp;&amp;</span> <span class="nx">action</span> <span class="o">!==</span> <span class="s1">&#39;set&#39;</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">silly</span><span class="p">(</span><span class="s1">&#39;Forever using options&#39;</span><span class="p">,</span> <span class="nx">options</span><span class="p">);</span>
- <span class="p">}</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>If there is no action then start in the current
-process with the specified <code>file</code> and <code>options</code>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">action</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">return</span> <span class="nx">cli</span><span class="p">.</span><span class="nx">start</span><span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="k">return</span> <span class="nb">Array</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">action</span><span class="p">)</span>
- <span class="o">?</span> <span class="nx">cli</span><span class="p">[</span><span class="nx">action</span><span class="p">[</span><span class="mi">0</span><span class="p">]](</span><span class="nx">action</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="nx">options</span><span class="p">)</span>
- <span class="o">:</span> <span class="nx">cli</span><span class="p">[</span><span class="nx">action</span><span class="p">](</span><span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <h3>function start (file, options, daemon)</h3>
-
-<h4>@file {string} Location of the script to spawn with forever</h4>
-
-<h4>@options {Object} Options to spawn the script <code>file</code> with.</h4>
-
-<h4>@daemon {boolean} Value indicating if we should spawn as a daemon</h4>
-
-<p>Starts a forever process for the script located at <code>file</code> with the
-specified <code>options</code>. If <code>daemon</code> is true, then the script will be
-started as a daemon process.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">start</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">,</span> <span class="nx">daemon</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">tryStart</span><span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">monitor</span> <span class="o">=</span> <span class="nx">daemon</span>
- <span class="o">?</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">startDaemon</span><span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">)</span>
- <span class="o">:</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">start</span><span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">);</span>
-
- <span class="nx">monitor</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;start&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">startServer</span><span class="p">(</span><span class="nx">monitor</span><span class="p">);</span>
- <span class="p">});</span>
- <span class="p">});</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <h3>function stop (file)</h3>
-
-<h4>@file {string} Target forever process to stop</h4>
-
-<p>Stops the forever process specified by <code>file</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">stop</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">file</span><span class="p">)</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">runner</span> <span class="o">=</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">stop</span><span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
-
- <span class="nx">runner</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;stop&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">process</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Forever stopped process:&#39;</span><span class="p">);</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">data</span><span class="p">(</span><span class="nx">process</span><span class="p">);</span>
- <span class="p">});</span>
-
- <span class="nx">runner</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Forever cannot find process with index: &#39;</span> <span class="o">+</span> <span class="nx">file</span><span class="p">)</span>
- <span class="p">});</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <h3>function stopall ()</h3>
-
-<p>Stops all currently running forever processes.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">stopall</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">runner</span> <span class="o">=</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">stopAll</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
- <span class="nx">runner</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;stopAll&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">processes</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">processes</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Forever stopped processes:&#39;</span><span class="p">);</span>
- <span class="nx">processes</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;\n&#39;</span><span class="p">).</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">line</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">data</span><span class="p">(</span><span class="nx">line</span><span class="p">);</span>
- <span class="p">});</span>
- <span class="p">}</span>
- <span class="k">else</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;No forever processes running&#39;</span><span class="p">);</span>
- <span class="p">}</span>
- <span class="p">});</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <h3>function restart (file)</h3>
-
-<h4>@file {string} Target process to restart</h4>
-
-<p>Restarts the forever process specified by <code>file</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">restart</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">file</span><span class="p">)</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">runner</span> <span class="o">=</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">restart</span><span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
- <span class="nx">runner</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;restart&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">processes</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">processes</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Forever restarted process(es):&#39;</span><span class="p">);</span>
- <span class="nx">processes</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;\n&#39;</span><span class="p">).</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">line</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">data</span><span class="p">(</span><span class="nx">line</span><span class="p">);</span>
- <span class="p">});</span>
- <span class="p">}</span>
- <span class="k">else</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;No forever processes running&#39;</span><span class="p">);</span>
- <span class="p">}</span>
- <span class="p">});</span>
-
- <span class="nx">runner</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Error restarting process: &#39;</span> <span class="o">+</span> <span class="nx">file</span><span class="p">.</span><span class="nx">grey</span><span class="p">);</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="nx">err</span><span class="p">.</span><span class="nx">message</span><span class="p">);</span>
- <span class="p">});</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <h3>function list ()</h3>
-
-<p>Lists all currently running forever processes.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">list</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">list</span><span class="p">(</span><span class="kc">true</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">processes</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">processes</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Forever processes running&#39;</span><span class="p">);</span>
- <span class="nx">processes</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;\n&#39;</span><span class="p">).</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">line</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">data</span><span class="p">(</span><span class="nx">line</span><span class="p">);</span>
- <span class="p">})</span>
- <span class="p">}</span>
- <span class="k">else</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;No forever processes running&#39;</span><span class="p">);</span>
- <span class="p">}</span>
- <span class="p">});</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <h3>function config ()</h3>
-
-<p>Lists all of the configuration in <code>~/.forever/config.json</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">config</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">keys</span> <span class="o">=</span> <span class="nb">Object</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">store</span><span class="p">),</span>
- <span class="nx">conf</span> <span class="o">=</span> <span class="nx">cliff</span><span class="p">.</span><span class="nx">inspect</span><span class="p">(</span><span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">store</span><span class="p">);</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="nx">keys</span><span class="p">.</span><span class="nx">length</span> <span class="o">&lt;=</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">conf</span> <span class="o">=</span> <span class="nx">conf</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\{\s/</span><span class="p">,</span> <span class="s1">&#39;{ \n&#39;</span><span class="p">)</span>
- <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\}/</span><span class="p">,</span> <span class="s1">&#39;\n}&#39;</span><span class="p">)</span>
- <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="s1">&#39;\033[90m&#39;</span><span class="p">,</span> <span class="s1">&#39; \033[90m&#39;</span><span class="p">)</span>
- <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/, /ig</span><span class="p">,</span> <span class="s1">&#39;,\n &#39;</span><span class="p">)</span>
- <span class="p">}</span>
- <span class="k">else</span> <span class="p">{</span>
- <span class="nx">conf</span> <span class="o">=</span> <span class="nx">conf</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\n\s{4}/ig</span><span class="p">,</span> <span class="s1">&#39;\n &#39;</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="nx">conf</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;\n&#39;</span><span class="p">).</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">line</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">data</span><span class="p">(</span><span class="nx">line</span><span class="p">);</span>
- <span class="p">});</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <h3>function set (key, value)</h3>
-
-<h4>@key {string} Key to set in forever config</h4>
-
-<h4>@value {string} Value to set for <code>key</code></h4>
-
-<p>Sets the specified <code>key</code> / <code>value</code> pair in the
-forever user config.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">set</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">,</span> <span class="nx">value</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">key</span> <span class="o">||</span> <span class="o">!</span><span class="nx">value</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">return</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Both &lt;key&gt; and &lt;value&gt; are required.&#39;</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="nx">updateConfig</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Setting forever config: &#39;</span> <span class="o">+</span> <span class="nx">key</span><span class="p">.</span><span class="nx">grey</span><span class="p">);</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="nx">key</span><span class="p">,</span> <span class="nx">value</span><span class="p">);</span>
- <span class="p">});</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <h3>function clear (key)</h3>
-
-<h4>@key {string} Key to remove from <code>~/.forever/config.json</code></h4>
-
-<p>Removes the specified <code>key</code> from the forever user config.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">clear</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">reserved</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="o">!==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">warn</span><span class="p">(</span><span class="s1">&#39;Cannot clear reserved config: &#39;</span> <span class="o">+</span> <span class="nx">key</span><span class="p">.</span><span class="nx">grey</span><span class="p">);</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">warn</span><span class="p">(</span><span class="s1">&#39;Use `forever set &#39;</span> <span class="o">+</span> <span class="nx">key</span> <span class="o">+</span> <span class="s1">&#39;` instead&#39;</span><span class="p">);</span>
- <span class="k">return</span><span class="p">;</span>
- <span class="p">}</span>
-
- <span class="nx">updateConfig</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Clearing forever config: &#39;</span> <span class="o">+</span> <span class="nx">key</span><span class="p">.</span><span class="nx">grey</span><span class="p">);</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">clear</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span>
- <span class="p">});</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#182;</a> </div> <h3>function columns (action, value)</h3>
-
-<h4>@action {string} The subaction to execute</h4>
-
-<h4>@value {Array} The value to use in the specified <code>action</code>.</h4>
-
-<p>Executes the specified subaction: <code>add</code>, <code>rm</code>, and <code>set</code> which
-add, remove, or completely overrides the columns used by <code>forever list</code>
-and <code>forever.list()</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">columns</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">action</span><span class="p">,</span> <span class="nx">value</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="o">!~</span><span class="p">[</span><span class="s1">&#39;add&#39;</span><span class="p">,</span> <span class="s1">&#39;rm&#39;</span><span class="p">,</span> <span class="s1">&#39;set&#39;</span><span class="p">].</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">action</span><span class="p">))</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Invalid action: &#39;</span> <span class="o">+</span> <span class="p">(</span><span class="s1">&#39;columns &#39;</span> <span class="o">+</span> <span class="nx">action</span><span class="p">).</span><span class="nx">yellow</span><span class="p">);</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Use: &#39;</span> <span class="o">+</span> <span class="s1">&#39;columns &lt;add|rm|set&gt;&#39;</span><span class="p">.</span><span class="nx">yellow</span><span class="p">);</span>
- <span class="k">return</span><span class="p">;</span>
- <span class="p">}</span>
-
- <span class="kd">var</span> <span class="nx">columns</span> <span class="o">=</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;columns&#39;</span><span class="p">),</span>
- <span class="nx">actions</span> <span class="o">=</span> <span class="p">{</span> <span class="nx">add</span><span class="o">:</span> <span class="nx">addColumn</span><span class="p">,</span> <span class="nx">rm</span><span class="o">:</span> <span class="nx">rmColumn</span><span class="p">,</span> <span class="nx">set</span><span class="o">:</span> <span class="nx">setColumns</span> <span class="p">},</span>
- <span class="nx">allColumns</span> <span class="o">=</span> <span class="nb">Object</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">forever</span><span class="p">.</span><span class="nx">columns</span><span class="p">);</span>
-
- <span class="kd">function</span> <span class="nx">addColumn</span> <span class="p">()</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="o">~</span><span class="nx">columns</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">value</span><span class="p">))</span> <span class="p">{</span>
- <span class="k">return</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">warn</span><span class="p">(</span><span class="nx">value</span><span class="p">.</span><span class="nx">magenta</span> <span class="o">+</span> <span class="s1">&#39; already exists in forever&#39;</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Adding column: &#39;</span> <span class="o">+</span> <span class="nx">value</span><span class="p">.</span><span class="nx">magenta</span><span class="p">);</span>
- <span class="nx">columns</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">value</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="kd">function</span> <span class="nx">rmColumn</span> <span class="p">()</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="o">!~</span><span class="nx">columns</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">value</span><span class="p">))</span> <span class="p">{</span>
- <span class="k">return</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">warn</span><span class="p">(</span><span class="nx">value</span><span class="p">.</span><span class="nx">magenta</span> <span class="o">+</span> <span class="s1">&#39; doesn\&#39;t exist in forever&#39;</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Removing column: &#39;</span> <span class="o">+</span> <span class="nx">value</span><span class="p">.</span><span class="nx">magenta</span><span class="p">);</span>
- <span class="nx">columns</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="nx">columns</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">value</span><span class="p">),</span> <span class="mi">1</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="kd">function</span> <span class="nx">setColumns</span> <span class="p">()</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Setting columns: &#39;</span> <span class="o">+</span> <span class="nx">value</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">).</span><span class="nx">magenta</span><span class="p">);</span>
- <span class="nx">columns</span> <span class="o">=</span> <span class="nx">value</span><span class="p">;</span>
- <span class="p">}</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="nx">action</span> <span class="o">!==</span> <span class="s1">&#39;set&#39;</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">value</span> <span class="o">=</span> <span class="nx">value</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
- <span class="p">}</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="o">!~</span><span class="nx">allColumns</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">value</span><span class="p">))</span> <span class="p">{</span>
- <span class="k">return</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Unknown column: &#39;</span> <span class="o">+</span> <span class="nx">value</span><span class="p">.</span><span class="nx">magenta</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="nx">actions</span><span class="p">[</span><span class="nx">action</span><span class="p">]();</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">&#39;columns&#39;</span><span class="p">,</span> <span class="nx">columns</span><span class="p">);</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">saveSync</span><span class="p">();</span>
-<span class="p">}</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">&#182;</a> </div> <h3>@private function (file, options, callback)</h3>
-
-<h4>@file {string} Target script to start</h4>
-
-<h4>@options {Object} Options to start the script with</h4>
-
-<h4>@callback {function} Continuation to respond to when complete.</h4>
-
-<p>Helper function that sets up the pathing for the specified <code>file</code>
-then stats the appropriate files and responds.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">function</span> <span class="nx">tryStart</span> <span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">fullLog</span><span class="p">,</span> <span class="nx">fullScript</span><span class="p">;</span>
-
- <span class="nx">fullLog</span> <span class="o">=</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">logFilePath</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">logFile</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">uid</span><span class="p">);</span>
- <span class="nx">fullScript</span> <span class="o">=</span> <span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">sourceDir</span><span class="p">,</span> <span class="nx">file</span><span class="p">);</span>
-
- <span class="nx">forever</span><span class="p">.</span><span class="nx">stat</span><span class="p">(</span><span class="nx">fullLog</span><span class="p">,</span> <span class="nx">fullScript</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">appendLog</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Cannot start forever&#39;</span><span class="p">);</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="nx">err</span><span class="p">.</span><span class="nx">message</span><span class="p">);</span>
- <span class="nx">process</span><span class="p">.</span><span class="nx">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="nx">callback</span><span class="p">();</span>
- <span class="p">});</span>
-<span class="p">}</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">&#182;</a> </div> <h3>@private function updateConfig (updater)</h3>
-
-<h4>@updater {function} Function which updates the forever config</h4>
-
-<p>Helper which runs the specified <code>updater</code> and then saves the forever
-config to <code>forever.config.get('root')</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">function</span> <span class="nx">updateConfig</span> <span class="p">(</span><span class="nx">updater</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">updater</span><span class="p">();</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">save</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">return</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Error saving config: &#39;</span> <span class="o">+</span> <span class="nx">err</span><span class="p">.</span><span class="nx">message</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="nx">cli</span><span class="p">.</span><span class="nx">config</span><span class="p">();</span>
- <span class="kd">var</span> <span class="nx">configFile</span> <span class="o">=</span> <span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;root&#39;</span><span class="p">),</span> <span class="s1">&#39;config.json&#39;</span><span class="p">);</span>
- <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Forever config saved: &#39;</span> <span class="o">+</span> <span class="nx">configFile</span><span class="p">.</span><span class="nx">yellow</span><span class="p">);</span>
- <span class="p">});</span>
-<span class="p">}</span>
-
-</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
274 docs/forever/monitor.html
@@ -1,274 +0,0 @@
-<!DOCTYPE html> <html> <head> <title>monitor.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//forever/cli.html"> forever/cli.html </a> <a class="source" href="..//forever/monitor.html"> forever/monitor.html </a> <a class="source" href="..//forever.html"> forever.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> monitor.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
-<span class="cm"> * monitor.js: Core functionality for the Monitor object.</span>
-<span class="cm"> *</span>
-<span class="cm"> * (C) 2010 Charlie Robbins</span>
-<span class="cm"> * MIT LICENCE</span>
-<span class="cm"> *</span>
-<span class="cm"> */</span>
-
-<span class="kd">var</span> <span class="nx">sys</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;sys&#39;</span><span class="p">),</span>
- <span class="nx">fs</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">),</span>
- <span class="nx">path</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;path&#39;</span><span class="p">),</span>
- <span class="nx">events</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;events&#39;</span><span class="p">),</span>
- <span class="nx">spawn</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;child_process&#39;</span><span class="p">).</span><span class="nx">spawn</span><span class="p">,</span>
- <span class="nx">winston</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;winston&#39;</span><span class="p">),</span>
- <span class="nx">forever</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;../forever&#39;</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>function Monitor (script, options)</h3>
-
-<h4>@script {string} Location of the target script to run.</h4>
-
-<h4>@options {Object} Configuration for this instance.</h4>
-
-<p>Creates a new instance of forever with specified params.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">Monitor</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">Monitor</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">script</span><span class="p">,</span> <span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
- <span class="nx">events</span><span class="p">.</span><span class="nx">EventEmitter</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Setup basic configuration options</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">options</span> <span class="o">=</span> <span class="nx">options</span> <span class="o">||</span> <span class="p">{};</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">silent</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">silent</span> <span class="o">||</span> <span class="kc">false</span><span class="p">;</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">forever</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">forever</span> <span class="o">||</span> <span class="kc">false</span><span class="p">;</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">uid</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">uid</span> <span class="o">||</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">randomString</span><span class="p">(</span><span class="mi">24</span><span class="p">);</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">pidFile</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">pidFile</span> <span class="o">||</span> <span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;pidPath&#39;</span><span class="p">),</span> <span class="k">this</span><span class="p">.</span><span class="nx">uid</span> <span class="o">+</span> <span class="s1">&#39;.pid&#39;</span><span class="p">);</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">max</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">max</span><span class="p">;</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">childExists</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">times</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Setup restart timing. These options control how quickly forever restarts
-a child process as well as when to kill a "spinning" process</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">this</span><span class="p">.</span><span class="nx">minUptime</span> <span class="o">=</span> <span class="k">typeof</span> <span class="nx">options</span><span class="p">.</span><span class="nx">minUptime</span> <span class="o">!==</span> <span class="s1">&#39;number&#39;</span> <span class="o">?</span> <span class="mi">0</span> <span class="o">:</span> <span class="nx">options</span><span class="p">.</span><span class="nx">minUptime</span><span class="p">;</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">spinSleepTime</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">spinSleepTime</span> <span class="o">||</span> <span class="kc">null</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Setup the command to spawn and the options to pass
-to that command.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">this</span><span class="p">.</span><span class="nx">command</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">command</span> <span class="o">||</span> <span class="s1">&#39;node&#39;</span><span class="p">;</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">options</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">options</span> <span class="o">||</span> <span class="p">[];</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">spawnWith</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">spawnWith</span> <span class="o">||</span> <span class="p">{};</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">sourceDir</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">sourceDir</span><span class="p">;</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">cwd</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">cwd</span> <span class="o">||</span> <span class="kc">null</span><span class="p">;</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">env</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">env</span> <span class="o">||</span> <span class="p">{};</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Setup log files and logger for this instance.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">this</span><span class="p">.</span><span class="nx">logFile</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">logFile</span> <span class="o">||</span> <span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;root&#39;</span><span class="p">),</span> <span class="k">this</span><span class="p">.</span><span class="nx">uid</span> <span class="o">+</span> <span class="s1">&#39;.log&#39;</span><span class="p">);</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">outFile</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">outFile</span><span class="p">;</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">errFile</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">errFile</span><span class="p">;</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">logger</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">logger</span> <span class="o">||</span> <span class="k">new</span> <span class="p">(</span><span class="nx">winston</span><span class="p">.</span><span class="nx">Logger</span><span class="p">)({</span>
- <span class="nx">transports</span><span class="o">:</span> <span class="p">[</span><span class="k">new</span> <span class="nx">winston</span><span class="p">.</span><span class="nx">transports</span><span class="p">.</span><span class="nx">Console</span><span class="p">({</span> <span class="nx">silent</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">silent</span> <span class="p">})]</span>
- <span class="p">});</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Extend from the winston logger.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">this</span><span class="p">.</span><span class="nx">logger</span><span class="p">.</span><span class="nx">extend</span><span class="p">(</span><span class="k">this</span><span class="p">);</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="nb">Array</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">script</span><span class="p">))</span> <span class="p">{</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">command</span> <span class="o">=</span> <span class="nx">script</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">options</span> <span class="o">=</span> <span class="nx">script</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span>
- <span class="p">}</span>
- <span class="k">else</span> <span class="p">{</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">unshift</span><span class="p">(</span><span class="nx">script</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">sourceDir</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">sourceDir</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">[</span><span class="mi">0</span><span class="p">]);</span>
- <span class="p">}</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>If we should log stdout, open a file buffer</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">outFile</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">stdout</span> <span class="o">=</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">createWriteStream</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">outFile</span><span class="p">,</span> <span class="p">{</span> <span class="nx">flags</span><span class="o">:</span> <span class="s1">&#39;a+&#39;</span><span class="p">,</span> <span class="nx">encoding</span><span class="o">:</span> <span class="s1">&#39;utf8&#39;</span><span class="p">,</span> <span class="nx">mode</span><span class="o">:</span> <span class="mi">0666</span> <span class="p">});</span>
- <span class="p">}</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>If we should log stderr, open a file buffer</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">errFile</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">stderr</span> <span class="o">=</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">createWriteStream</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">errFile</span><span class="p">,</span> <span class="p">{</span> <span class="nx">flags</span><span class="o">:</span> <span class="s1">&#39;a+&#39;</span><span class="p">,</span> <span class="nx">encoding</span><span class="o">:</span> <span class="s1">&#39;utf8&#39;</span><span class="p">,</span> <span class="nx">mode</span><span class="o">:</span> <span class="mi">0666</span> <span class="p">});</span>
- <span class="p">}</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>Last if any hooks have been passed in attach
-this instance to them</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">hooks</span> <span class="o">&amp;&amp;</span> <span class="nx">options</span><span class="p">.</span><span class="nx">hooks</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">options</span><span class="p">.</span><span class="nx">hooks</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">hook</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">hook</span> <span class="o">===</span> <span class="s1">&#39;function&#39;</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">return</span> <span class="nx">hook</span><span class="p">(</span><span class="nx">self</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="nx">hook</span><span class="p">.</span><span class="nx">attach</span><span class="p">(</span><span class="nx">self</span><span class="p">);</span>
- <span class="p">});</span>
- <span class="p">}</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <p>Inherit from events.EventEmitter</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">sys</span><span class="p">.</span><span class="nx">inherits</span><span class="p">(</span><span class="nx">Monitor</span><span class="p">,</span> <span class="nx">events</span><span class="p">.</span><span class="nx">EventEmitter</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#182;</a> </div> <h3>function start ([restart])</h3>
-
-<h4>@restart {boolean} Value indicating whether this is a restart.</h4>
-
-<p>Start the process that this instance is configured for</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Monitor</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">start</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">restart</span><span class="p">)</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">running</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">restart</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">process</span><span class="p">.</span><span class="nx">nextTick</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="nx">self</span><span class="p">.</span><span class="nx">emit</span><span class="p">(</span><span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Cannot start process that is already running.&#39;</span><span class="p">));</span>
- <span class="p">});</span>
- <span class="p">}</span>
-
- <span class="kd">var</span> <span class="nx">child</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">trySpawn</span><span class="p">();</span>
- <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">child</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">process</span><span class="p">.</span><span class="nx">nextTick</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="nx">self</span><span class="p">.</span><span class="nx">emit</span><span class="p">(</span><span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Target script does not exist: &#39;</span> <span class="o">+</span> <span class="nx">self</span><span class="p">.</span><span class="nx">options</span><span class="p">[</span><span class="mi">0</span><span class="p">]));</span>
- <span class="p">});</span>
- <span class="k">return</span> <span class="k">this</span><span class="p">;</span>
- <span class="p">}</span>
-
- <span class="k">this</span><span class="p">.</span><span class="nx">ctime</span> <span class="o">=</span> <span class="nb">Date</span><span class="p">.</span><span class="nx">now</span><span class="p">();</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">child</span> <span class="o">=</span> <span class="nx">child</span><span class="p">;</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">running</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
-
- <span class="nx">process</span><span class="p">.</span><span class="nx">nextTick</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="nx">self</span><span class="p">.</span><span class="nx">emit</span><span class="p">(</span><span class="nx">restart</span> <span class="o">?</span> <span class="s1">&#39;restart&#39;</span> <span class="o">:</span> <span class="s1">&#39;start&#39;</span><span class="p">,</span> <span class="nx">self</span><span class="p">,</span> <span class="nx">self</span><span class="p">.</span><span class="nx">data</span><span class="p">);</span>
- <span class="p">});</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">&#182;</a> </div> <p>Hook all stream data and process it</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">function</span> <span class="nx">listenTo</span> <span class="p">(</span><span class="nx">stream</span><span class="p">)</span> <span class="p">{</span>
- <span class="kd">function</span> <span class="nx">ldata</span> <span class="p">(</span><span class="nx">data</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">self</span><span class="p">.</span><span class="nx">silent</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">self</span><span class="p">[</span><span class="nx">stream</span><span class="p">])</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">&#182;</a> </div> <p>If we haven't been silenced, and we don't have a file stream
-to output to write to the process stdout stream</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">process</span><span class="p">.</span><span class="nx">stdout</span><span class="p">.</span><span class="nx">write</span><span class="p">(</span><span class="nx">data</span><span class="p">);</span>
- <span class="p">}</span>
- <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">self</span><span class="p">[</span><span class="nx">stream</span><span class="p">])</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-15">&#182;</a> </div> <p>If we have been given an output file for the stream, write to it</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">self</span><span class="p">[</span><span class="nx">stream</span><span class="p">].</span><span class="nx">write</span><span class="p">(</span><span class="nx">data</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="nx">self</span><span class="p">.</span><span class="nx">emit</span><span class="p">(</span><span class="nx">stream</span><span class="p">,</span> <span class="nx">data</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="nx">child</span><span class="p">[</span><span class="nx">stream</span><span class="p">].</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="nx">ldata</span><span class="p">);</span>
-
- <span class="nx">child</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;exit&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="nx">child</span><span class="p">[</span><span class="nx">stream</span><span class="p">].</span><span class="nx">removeListener</span><span class="p">(</span><span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="nx">ldata</span><span class="p">);</span>
- <span class="p">});</span>
- <span class="p">}</span></pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-16">&#182;</a> </div> <p>Listen to stdout and stderr</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">listenTo</span><span class="p">(</span><span class="s1">&#39;stdout&#39;</span><span class="p">);</span>
- <span class="nx">listenTo</span><span class="p">(</span><span class="s1">&#39;stderr&#39;</span><span class="p">);</span>
-
- <span class="nx">child</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;exit&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">code</span><span class="p">)</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">spinning</span> <span class="o">=</span> <span class="nb">Date</span><span class="p">.</span><span class="nx">now</span><span class="p">()</span> <span class="o">-</span> <span class="nx">self</span><span class="p">.</span><span class="nx">ctime</span> <span class="o">&lt;</span> <span class="nx">self</span><span class="p">.</span><span class="nx">minUptime</span><span class="p">;</span>
- <span class="nx">self</span><span class="p">.</span><span class="nx">warn</span><span class="p">(</span><span class="s1">&#39;Forever detected script exited with code: &#39;</span> <span class="o">+</span> <span class="nx">code</span><span class="p">);</span>
-
- <span class="kd">function</span> <span class="nx">letChildDie</span><span class="p">()</span> <span class="p">{</span>
- <span class="nx">self</span><span class="p">.</span><span class="nx">running</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-17"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-17">&#182;</a> </div> <p>If had to write to an stdout file, close it</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">stdout</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">self</span><span class="p">.</span><span class="nx">stdout</span><span class="p">.</span><span class="nx">end</span><span class="p">();</span>
- <span class="p">}</span></pre></div> </td> </tr> <tr id="section-18"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-18">&#182;</a> </div> <p>If had to write to an stderr file, close it</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">stderr</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">self</span><span class="p">.</span><span class="nx">stderr</span><span class="p">.</span><span class="nx">end</span><span class="p">();</span>
- <span class="p">}</span>
-
- <span class="nx">self</span><span class="p">.</span><span class="nx">emit</span><span class="p">(</span><span class="s1">&#39;exit&#39;</span><span class="p">,</span> <span class="nx">self</span><span class="p">,</span> <span class="nx">spinning</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="kd">function</span> <span class="nx">restartChild</span><span class="p">()</span> <span class="p">{</span>
- <span class="nx">process</span><span class="p">.</span><span class="nx">nextTick</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="nx">self</span><span class="p">.</span><span class="nx">warn</span><span class="p">(</span><span class="s1">&#39;Forever restarting script for &#39;</span> <span class="o">+</span> <span class="nx">self</span><span class="p">.</span><span class="nx">times</span> <span class="o">+</span> <span class="s1">&#39; time&#39;</span><span class="p">);</span>
- <span class="nx">self</span><span class="p">.</span><span class="nx">start</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
- <span class="p">});</span>
- <span class="p">}</span>
-
- <span class="nx">self</span><span class="p">.</span><span class="nx">times</span><span class="o">++</span><span class="p">;</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">forceStop</span> <span class="o">||</span> <span class="p">(</span><span class="o">!</span><span class="nx">self</span><span class="p">.</span><span class="nx">forever</span> <span class="o">&amp;&amp;</span> <span class="nx">self</span><span class="p">.</span><span class="nx">times</span> <span class="o">&gt;=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">max</span><span class="p">)</span>
- <span class="o">||</span> <span class="p">(</span><span class="nx">spinning</span> <span class="o">&amp;&amp;</span> <span class="k">typeof</span> <span class="nx">self</span><span class="p">.</span><span class="nx">spinSleepTime</span> <span class="o">!==</span> <span class="s1">&#39;number&#39;</span><span class="p">))</span> <span class="p">{</span>
- <span class="nx">letChildDie</span><span class="p">();</span>
- <span class="p">}</span>
- <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">spinning</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">setTimeout</span><span class="p">(</span><span class="nx">restartChild</span><span class="p">,</span> <span class="nx">self</span><span class="p">.</span><span class="nx">spinSleepTime</span><span class="p">);</span>
- <span class="p">}</span>
- <span class="k">else</span> <span class="p">{</span>
- <span class="nx">restartChild</span><span class="p">();</span>
- <span class="p">}</span>
- <span class="p">});</span>
-
- <span class="k">return</span> <span class="k">this</span><span class="p">;</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-19"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-19">&#182;</a> </div> <h3>function trySpawn()</h3>
-
-<p>Tries to spawn the target Forever child process. Depending on
-configuration, it checks the first argument of the options
-to see if the file exists. This is useful is you are
-trying to execute a script with an env: e.g. node myfile.js</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Monitor</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">trySpawn</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">command</span> <span class="o">===</span> <span class="s1">&#39;node&#39;</span> <span class="o">||</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">checkFile</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">childExists</span><span class="p">))</span> <span class="p">{</span>
- <span class="k">try</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">stats</span> <span class="o">=</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">statSync</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">[</span><span class="mi">0</span><span class="p">]);</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">childExists</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
- <span class="p">}</span>
- <span class="k">catch</span> <span class="p">(</span><span class="nx">ex</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
- <span class="p">}</span>
- <span class="p">}</span>
-
- <span class="k">this</span><span class="p">.</span><span class="nx">spawnWith</span><span class="p">.</span><span class="nx">cwd</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">cwd</span> <span class="o">||</span> <span class="k">this</span><span class="p">.</span><span class="nx">spawnWith</span><span class="p">.</span><span class="nx">cwd</span><span class="p">;</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">spawnWith</span><span class="p">.</span><span class="nx">env</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_getEnv</span><span class="p">();</span>
-
- <span class="k">return</span> <span class="nx">spawn</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">command</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">spawnWith</span><span class="p">);</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-20"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-20">&#182;</a> </div> <h3>@data {Object}</h3>
-
-<p>Responds with the appropriate information about
-this <code>Monitor</code> instance and it's associated child process.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Monitor</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">__defineGetter__</span><span class="p">(</span><span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">running</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-21"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-21">&#182;</a> </div> <p>TODO: Return settings from this forever instance
-with a state indicator that it is currently stopped.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">return</span> <span class="p">{};</span>
- <span class="p">}</span>
-
- <span class="kd">var</span> <span class="nx">childData</span> <span class="o">=</span> <span class="p">{</span>
- <span class="nx">ctime</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">ctime</span><span class="p">,</span>
- <span class="nx">command</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">command</span><span class="p">,</span>
- <span class="nx">file</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
- <span class="nx">foreverPid</span><span class="o">:</span> <span class="nx">process</span><span class="p">.</span><span class="nx">pid</span><span class="p">,</span>
- <span class="nx">logFile</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">logFile</span><span class="p">,</span>
- <span class="nx">options</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span>
- <span class="nx">pid</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">child</span><span class="p">.</span><span class="nx">pid</span><span class="p">,</span>
- <span class="nx">silent</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">silent</span><span class="p">,</span>
- <span class="nx">uid</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">uid</span>
- <span class="p">};</span>
-
- <span class="p">[</span><span class="s1">&#39;pidFile&#39;</span><span class="p">,</span> <span class="s1">&#39;outFile&#39;</span><span class="p">,</span> <span class="s1">&#39;errFile&#39;</span><span class="p">,</span> <span class="s1">&#39;env&#39;</span><span class="p">,</span> <span class="s1">&#39;cwd&#39;</span><span class="p">].</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">self</span><span class="p">[</span><span class="nx">key</span><span class="p">])</span> <span class="p">{</span>
- <span class="nx">childData</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">self</span><span class="p">[</span><span class="nx">key</span><span class="p">];</span>
- <span class="p">}</span>
- <span class="p">});</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">sourceDir</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">childData</span><span class="p">.</span><span class="nx">sourceDir</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">sourceDir</span><span class="p">;</span>
- <span class="nx">childData</span><span class="p">.</span><span class="nx">file</span> <span class="o">=</span> <span class="nx">childData</span><span class="p">.</span><span class="nx">file</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">sourceDir</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="k">this</span><span class="p">.</span><span class="nx">childData</span> <span class="o">=</span> <span class="nx">childData</span><span class="p">;</span>
- <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">childData</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-22"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-22">&#182;</a> </div> <p>Setup the forever process to listen to
-SIGINT and SIGTERM events so that we can
-clean up the *.pid file</p>
-
-<p>Remark: This should work, but the fd gets screwed up
- with the daemon process.</p>
-
-<p>process.on('SIGINT', function () {
- process.exit(0);
-});</p>
-
-<p>process.on('SIGTERM', function () {
- process.exit(0);
-});
-process.on('exit', function () {
- fs.unlinkSync(childPath);
-});</p> </td> <td class="code"> <div class="highlight"><pre><span class="p">});</span></pre></div> </td> </tr> <tr id="section-23"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-23">&#182;</a> </div> <h3>function restart ()</h3>
-
-<p>Restarts the target script associated with this instance.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Monitor</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">restart</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">kill</span><span class="p">(</span><span class="kc">false</span><span class="p">);</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-24"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-24">&#182;</a> </div> <h3>function stop ()</h3>
-
-<p>Stops the target script associated with this instance. Prevents it from auto-respawning</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Monitor</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">stop</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">kill</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-25"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-25">&#182;</a> </div> <h3>function kill (forceStop)</h3>
-
-<h4>@forceStop {boolean} Value indicating whether short circuit forever auto-restart.</h4>
-
-<p>Kills the ChildProcess object associated with this instance.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Monitor</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">kill</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">forceStop</span><span class="p">)</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">child</span> <span class="o">||</span> <span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">running</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">process</span><span class="p">.</span><span class="nx">nextTick</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="nx">self</span><span class="p">.</span><span class="nx">emit</span><span class="p">(</span><span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Cannot stop process that is not running.&#39;</span><span class="p">));</span>
- <span class="p">});</span>
- <span class="p">}</span>
- <span class="k">else</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-26"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-26">&#182;</a> </div> <p>Set an instance variable here to indicate this
-stoppage is forced so that when <code>child.on('exit', ..)</code>
-fires in <code>Monitor.prototype.start</code> we can short circuit
-and prevent auto-restart</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">forceStop</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">forceStop</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
- <span class="p">}</span>
-
- <span class="k">this</span><span class="p">.</span><span class="nx">child</span><span class="p">.</span><span class="nx">kill</span><span class="p">();</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">emit</span><span class="p">(</span><span class="s1">&#39;stop&#39;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">childData</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="k">return</span> <span class="k">this</span><span class="p">;</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-27"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-27">&#182;</a> </div> <h3>@private function _getEnv ()</h3>
-
-<p>Returns the environment variables that should be passed along
-to the target process spawned by this instance.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Monitor</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_getEnv</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">,</span>
- <span class="nx">extra</span> <span class="o">=</span> <span class="nb">Object</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">env</span><span class="p">),</span>
- <span class="nx">merged</span> <span class="o">=</span> <span class="p">{};</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="nx">extra</span><span class="p">.</span><span class="nx">length</span> <span class="o">===</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">return</span> <span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">;</span>
- <span class="p">}</span>
-
- <span class="kd">function</span> <span class="nx">addKey</span> <span class="p">(</span><span class="nx">key</span><span class="p">,</span> <span class="nx">source</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">merged</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">source</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span>
- <span class="p">}</span></pre></div> </td> </tr> <tr id="section-28"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-28">&#182;</a> </div> <p>Mixin the key:value pairs from <code>process.env</code> and the custom
-environment variables in <code>this.env</code>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nb">Object</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">).</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">k</span><span class="p">)</span> <span class="p">{</span> <span class="nx">addKey</span><span class="p">(</span><span class="nx">k</span><span class="p">,</span> <span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">)</span> <span class="p">});</span>
- <span class="nx">extra</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">k</span><span class="p">)</span> <span class="p">{</span> <span class="nx">addKey</span><span class="p">(</span><span class="nx">k</span><span class="p">,</span> <span class="nx">self</span><span class="p">.</span><span class="nx">env</span><span class="p">)</span> <span class="p">});</span>
-
- <span class="k">return</span> <span class="nx">merged</span><span class="p">;</span>
-<span class="p">};</span>
-
-</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
Please sign in to comment.
Something went wrong with that request. Please try again.