コマンドライン オプション

□未翻訳

□翻訳中

□翻訳完了(細田謙二)

■レビュー(中垣健志)

コマンドライン オプション

GUIを表示せずにweb2pyを開始させるには、コマンドラインから次のように入力します:

It is possible to skip the GUI and start web2py directly from the command line by typing something like:

1.

python web2py.py -a 'your password' -i 127.0.0.1 -p 8000

web2pyが起動すると、パスワードのハッシュ値を保存する場所として"parameters_8000.py"ファイルが作成されます。"<ask>"をパスワードとして入力すると、パスワードを入力するプロンプトが表示されます。

When web2py starts, it creates a file called "parameters_8000.py" where it stores the hashed password. If you use "<ask>" as the password, web2py prompts you for it.

セキュリティ向上のため、次のようにweb2pyを起動することができます:

For additional security, you can start web2py with:

1.

python web2py.py -a '<recycle>' -i 127.0.0.1 -p 8000

この場合、web2pyは以前に保存したパスワードのハッシュ値を再利用します。パスワードが提供されていない場合、つまり、"parameters_8000.py"ファイルが削除されていた場合は、Webベースの管理インターフェイスは無効になります。

In this case web2py reuses the previously stored hashed password. If no password is provided, or if the "parameters_8000.py" file is deleted, the web-based administrative interface is disabled.

いくつかのUnix / Linuxシステムでは、次のようにパスワードを指定すると、

On some Unix/Linux systems, if the password is

1.

<pam_user:some_user>

管理者認証のために用いられるsome_userのオペレーティングシステムアカウントのPAMパスワードが、PAMの設定でブロックしていない限り、使用されます。

web2py uses the PAM password of the Operating System account of some_user to authenticate the administrator, unless blocked by the PAM configuration.

web2pyは通常CPython(Guido van Rossumによって作成されたC言語で実装されたPython)で動作します。しかしJython(Javaによる実装)でも動作できます。後者によって、J2EE上でweb2pyを動かせることができるかもしれません。Jythonを使うには、単に"python web2py.py ..."を"jython web2py.py"と置き換えるだけです。Jythonのインストールの詳細、データベースのアクセスに必要なzxJDBCモジュールは、第12章で説明します。

web2py normally runs with CPython (the C implementation of the Python interpreter created by Guido van Rossum), but it can also run with Jython (the Java implementation of the interpreter). The latter possibility allows the use of web2py in the context of a J2EE infrastructure. To use Jython, simply replace "python web2py.py ..." with "jython web2py.py". Details about installing Jython, zxJDBC modules required to access the databases can be found in Chapter 12.

"web2py.py"スクリプトは、多くのコマンドライン引数を取ることができます。その中には、スレッドの最大数やSSLの有効化などがあります。以下はその一通りのリストです:

The "web2py.py" script can take many command-line arguments specifying the maximum number of threads, enabling of SSL, etc. For a complete list type:

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.

12.

13.

14.

15.

16.

17.

18.

19.

20.

21.

22.

23.

24.

25.

26.

27.

28.

29.

30.

31.

32.

33.

34.

35.

36.

37.

38.

39.

40.

41.

42.

43.

44.

45.

46.

47.

48.

49.

50.

51.

52.

53.

54.

55.

56.

57.

58.

59.

60.

61.

62.

63.

64.

65.

66.

67.

68.

69.

70.

71.

72.

73.

74.

75.

76.

>>> python web2py.py -h

Usage: python web2py.py

web2py Web Framework startup script. ATTENTION: unless a password

is specified (-a 'passwd'), web2py will attempt to run a GUI.

In this case command line options are ignored.

Options:

--version show program's version number and exit

-h, --help show this help message and exit

-i IP, --ip=IP ip address of the server (127.0.0.1)

-p PORT, --port=PORT port of server (8000)

-a PASSWORD, --password=PASSWORD

password to be used for administration

use -a "<recycle>" to reuse the last

password

-u UPGRADE, --upgrade=UPGRADE

-u yes: upgrade applications and exit

-c SSL_CERTIFICATE, --ssl_certificate=SSL_CERTIFICATE

file that contains ssl certificate

-k SSL_PRIVATE_KEY, --ssl_private_key=SSL_PRIVATE_KEY

file that contains ssl private key

-d PID_FILENAME, --pid_filename=PID_FILENAME

file to store the pid of the server

-l LOG_FILENAME, --log_filename=LOG_FILENAME

file to log connections

--minthreads=MINTHREADS

minimum number of server threads

--maxthreads=MAXTHREADS

maximum number of server threads

(set to 0 for unlimited threads)

-s SERVER_NAME, --server_name=SERVER_NAME

server name for the web server

-q REQUEST_QUEUE_SIZE, --request_queue_size=REQUEST_QUEUE_SIZE

max number of queued requests when server unavailable

-o TIMEOUT, --timeout=TIMEOUT

timeout for individual request (10 seconds)

-z SHUTDOWN_TIMEOUT, --shutdown_timeout=SHUTDOWN_TIMEOUT

timeout on shutdown of server (5 seconds)

-f FOLDER, --folder=FOLDER

folder from which to run web2py

-v, --verbose increase --test verbosity

-Q, --quiet disable all output

-D DEBUGLEVEL, --debug=DEBUGLEVEL

set debug output level (0-100, 0 means all,

100 means none; default is 30)

-S APPNAME, --shell=APPNAME

run web2py in interactive shell or IPython

(if installed) with specified appname

-P, --plain only use plain python shell; should be used

with --shell option

-M, --import_models auto import model files; default is False;

should be used with --shell option

-R PYTHON_FILE, --run=PYTHON_FILE

run PYTHON_FILE in web2py environment;

should be used with --shell option

-T TEST_PATH, --test=TEST_PATH

run doctests in web2py environment;

TEST_PATH like a/c/f (c,f optional)

-W WINSERVICE, --winservice=WINSERVICE

-W install|start|stop as Windows service

-C, --cron trigger a cron run manually; usually invoked

from a system crontab

-N, --no-cron do not start cron automatically

-L CONFIG, --config=CONFIG

config file

-F PROFILER_FILENAME, --profiler=PROFILER_FILENAME

profiler filename

-t, --taskbar use web2py gui and run in taskbar

(system tray)

--nogui text-only, no GUI

-A ARGS, --args=ARGS should be followed by a list of arguments to be passed

to script, to be used with -S, -A must be the last

option

--interfaces=INTERFACES

allows multiple interfaces to be served

小文字のオプションは、Webサーバーを設定するために使用されます。-Lオプションは設定オプションをファイルから読み込むようにします。-Wはweb2pyをWindowsサービスとしてインストールします。-S、-P、-Mオプションは、インタラクティブなPythonのシェルを開始します。-Tオプションは、web2pyの実行環境にあるコントローラのdoctestを探し、実行します。次の例は、"welcome"アプリケーションのすべてのコントローラのdoctestを実行します:

Lower-case options are used to configure the web server. The -L option tells web2py to read configuration options from a file, -W installs web2py as a windows service, while -S, -P and -Moptions start an interactive Python shell. The -T option finds and runs controller doctests in a web2py execution environment. For example, the following example runs doctests from all controllers in the "welcome" application:

1.

python web2py.py -vT welcome

web2pyをWindowsサービスとして実行している場合( -Wオプション)、コマンドライン引数から設定を行うのは手間がかかります。このため、web2pyのフォルダには、サンプルとして"options_std.py"が内部Webサーバーの設定ファイルとして用意されています:

if you run web2py as Windows Service, -W, it is not convenient to pass the configuration using command line arguments. For this reason, in the web2py folder there is a sample "options_std.py" configuration file for the internal web server:

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.

12.

13.

14.

import socket, os

ip = '127.0.0.1'

port = 8000

password = '<recycle>' ### <recycle> means use the previous password

pid_filename = 'httpserver.pid'

log_filename = 'httpserver.log'

ssl_certificate = " ### path to certificate file

ssl_private_key = " ### path to private key file

numthreads = 10

server_name = socket.gethostname()

request_queue_size = 5

timeout = 10

shutdown_timeout = 5

folder = os.getcwd()

このファイルには、web2pyのデフォルト値が含まれています。このファイルを編集した場合、-Lコマンドラインオプションを用いて明示的にインポートする必要があります。なお、これはweb2pyをWindowsサービスとして動作させた場合のみ機能します。

This file contains the web2py defaults. If you edit this file, you need to import it explicitly with the -L command-line option. It only works if you run web2py as a Windows Service.