Help:Extension/ScriptFunctions

From Metabolomics.JP
(Difference between revisions)
Jump to: navigation, search
 
(17 intermediate revisions by one user not shown)
Line 1: Line 1:
 
{{Extension
 
{{Extension
 
|author=K, Suwa
 
|author=K, Suwa
|version=0.1
+
|version=0.2
|mediawiki=1.11.1
+
|type=Parser function
 
}}
 
}}
  
 
__TOC__
 
__TOC__
  
外部スクリプトを使えるようにするextensionです。
+
Extension to use an external scripting language, Lua.
現在使えるのはluaのみです。
+
  
luaが無限ループに陥った場合などの対処として、script_monitoring.shをcrondで実行し、10秒以上実行されているluaプログラムを停止(kill)します。
+
Since an infinite loop can be achieved by Lua, script_monitoring.sh run by crond will kill all Lua processes running longer than 10 seconds.
 +
 
 +
For security, Lua's io, debug, package, os library are nullified. Also, the program halts when it finds 'dofile'.
 +
 
 +
== Example ==
 +
===<nowiki>{{#lua:luaコード|標準入力}}</nowiki>===
 +
第一引数にコード、第二引数に標準入力文字列を渡します。第二引数はコード中で「stdin」として利用できます。
 +
* ソース
 +
<nowiki>{{#lua:print(stdin)|input string}}</nowiki>
 +
 
 +
* 実行例
 +
{{#lua:print(stdin)|input string}}
  
 
== Requirements ==
 
== Requirements ==
[http://www.lua.org/ lua]
+
* [http://www.lua.org/ lua]
  
 
== Download ==
 
== Download ==
 
<table border="1" cellpadding="3" cellspacing="1">
 
<table border="1" cellpadding="3" cellspacing="1">
  <tr><td>version</td><td>source</td><td>size</td></tr>
+
  <tr><td>version</td><td>source</td><td>md5</td><td>OperationCheck version</td></tr>
  <tr><td>0.1(September 11,2008)</td><td>ScriptFunctions.phps</td><td></td></tr>
+
  <tr><td>0.2(July 31,2010)</td><td>{{#ifexistfile:/data/src/ScriptFunctions/ScriptFunctions.phps}}</td><td><pre style="border: 0px; background-color: white; padding: 0em; line-height: 0em">06836d5073909109d6cbc5dc976d8456</pre></td><td>1.11.1, 1.16.2</td></tr>
 +
<tr><td>0.1(October 7,2008)</td><td>{{#ifexistfile:/data/src/ScriptFunctions/previous/ScriptFunctions-0.1.phps}}</td><td><pre style="border: 0px; background-color: white; padding: 0em; line-height: 0em">394b55519d7449f06cbf34b4ed845570</pre></td><td>1.11.1</td></tr>
 
</table>
 
</table>
  
  
 
<table border="1" cellpadding="3" cellspacing="1">
 
<table border="1" cellpadding="3" cellspacing="1">
  <tr><td>version</td><td>source</td><td>size</td></tr>
+
  <tr><td>version</td><td>source</td><td>md5</td></tr>
  <tr><td>0.1(September 11,2008)</td><td>script_monitoring.sh</td><td></td></tr>
+
  <tr><td>0.1(September 30,2008)</td><td>{{#ifexistfile:/data/src/ScriptFunctions/script_monitoring.sh}}</td><td><pre style="border: 0px; background-color: white; padding: 0em; line-height: 0em">eedd37d4618802a48fd5b26d8dbfedfb</pre></td></tr>
 
</table>
 
</table>
  
 
== Installtion ==
 
== Installtion ==
 
<ol>
 
<ol>
  <li>Download source and rename to ScriptFunctions.php and script_monitoring.sh.</li>
+
  <li>Download the source code and rename it to ScriptFunctions.php and script_monitoring.sh.</li>
  <li>Put in extensions/ directory.</li>
+
  <li>Place it in the extensions/ directory.</li>
  <li>Insert follow line to LocalSettings.php
+
  <li>Insert the follow lines to LocalSettings.php
  <pre>require_once( "$IP/extensions/ScritFunctions.php" );
+
  <pre>require_once( "$IP/extensions/ScriptFunctions.php" );
 
$egLuaPath = "path to directory which in lua binary";
 
$egLuaPath = "path to directory which in lua binary";
 
$egTmpPath = "path to tmp directory"; ( default: "/tmp" )</pre>
 
$egTmpPath = "path to tmp directory"; ( default: "/tmp" )</pre>
$egLuaPathを定義しなかった場合、プログラムは実行されません。<br>
+
$egLuaPath is required.<br>
$egTmpPathはluaプログラムを一時的に保存する場所です。</li>
+
$egTmpPath is a temporary place to save Lua programs.</li>
 
  <li>Put in any direcotry.( ideal: /etc/cron.d/ )</li>
 
  <li>Put in any direcotry.( ideal: /etc/cron.d/ )</li>
 
  <li>Insert follow line to /etc/crontab
 
  <li>Insert follow line to /etc/crontab
  <pre>* * * * * root /etc/cron.d/lua_monitoring.sh</pre></li>
+
  <pre>* * * * * root /etc/cron.d/script_monitoring.sh</pre></li>
 +
<li>実行可能パーミッションを付加します。 Give executable permission.
 +
<pre>chmod 755 /etc/cron.d/script_monitoring.sh</pre></li>
 
</ol>
 
</ol>
  
 
== Function ==
 
== Function ==
# [[Doc:Extensions#.7B.7B.23lua:program.7Carg.7D.7D|lua]]
+
# [[Help:Extensions#.7B.7B.23lua:program.7Carg.7D.7D|lua]]
 +
 
 +
== ChangeLog ==
 +
0.2
 +
* 引数に"<nowiki>[[-]]</nowiki>"を受け取れないバグを修正しました。
 +
* mediawiki 1.12に対応しました。

Latest revision as of 14:26, 1 March 2011

Extension Information
Implementation
Description
Author(s)K, Suwa
Version0.2
MediaWiki
License
Hooks used
Token typeParser function

Contents


Extension to use an external scripting language, Lua.

Since an infinite loop can be achieved by Lua, script_monitoring.sh run by crond will kill all Lua processes running longer than 10 seconds.

For security, Lua's io, debug, package, os library are nullified. Also, the program halts when it finds 'dofile'.

[edit] Example

[edit] {{#lua:luaコード|標準入力}}

第一引数にコード、第二引数に標準入力文字列を渡します。第二引数はコード中で「stdin」として利用できます。

  • ソース
{{#lua:print(stdin)|input string}}
  • 実行例

input string


[edit] Requirements

[edit] Download

versionsourcemd5OperationCheck version
0.2(July 31,2010)ScriptFunctions.phps
06836d5073909109d6cbc5dc976d8456
1.11.1, 1.16.2
0.1(October 7,2008)ScriptFunctions-0.1.phps
394b55519d7449f06cbf34b4ed845570
1.11.1


versionsourcemd5
0.1(September 30,2008)script_monitoring.sh
eedd37d4618802a48fd5b26d8dbfedfb

[edit] Installtion

  1. Download the source code and rename it to ScriptFunctions.php and script_monitoring.sh.
  2. Place it in the extensions/ directory.
  3. Insert the follow lines to LocalSettings.php
    require_once( "$IP/extensions/ScriptFunctions.php" );
    $egLuaPath = "path to directory which in lua binary";
    $egTmpPath = "path to tmp directory"; ( default: "/tmp" )

    $egLuaPath is required.

    $egTmpPath is a temporary place to save Lua programs.
  4. Put in any direcotry.( ideal: /etc/cron.d/ )
  5. Insert follow line to /etc/crontab
    * * * * * root /etc/cron.d/script_monitoring.sh
  6. 実行可能パーミッションを付加します。 Give executable permission.
    chmod 755 /etc/cron.d/script_monitoring.sh

[edit] Function

  1. lua

[edit] ChangeLog

0.2

  • 引数に"[[-]]"を受け取れないバグを修正しました。
  • mediawiki 1.12に対応しました。
Personal tools
Namespaces

Variants
Actions
Navigation
metabolites
Toolbox