目的
/usr/afs/local/BosConfig ファイルに新しいプロセスを定義して、実行を開始します。
構文
bos create -server <machine name> -instance <server process name>
-type <server type> -cmd <command lines>+
[-notifier <Notifier program>] [-cell <cell name>]
[-noauth] [-localauth] [-help]
bos c -s <machine name> -i <server process name> -t <server type>
-cm <command lines>+ [-not <Notifier program>] [-ce <cell name>]
[-noa] [-l] [-h]
構文
bos create コマンドは、 -server 引き数で指定されたサーバー・マシン上の /usr/afs/local/BosConfig ファイルにサーバー・プロセス項目を作成し、プロセスの状況を BosConfig ファイルおよびメモリー内で Run に設定し、そのプロセスを開始します。
BosConfig ファイルのサーバー・プロセス項目には、サーバー・プロセスの名前、タイプ、初期化するコマンドが定義されます。またオプションで、プロセス終了時に実行する通知プログラム名が定義されます。
オプション
simpleプロセスの場合には、ローカル・ディスクにあるプロセスのバイナリー・ファイルを完全なパス名で指定してください。(たとえば、保護サーバーの場合には /usr/afs/bin/ptserver) 初期化コマンドのオプションを使用する場合には、コマンド全体を二重引用符 (" ") で囲んでください。 upclient プロセスには必須の引き数があり、それ以外のプロセスに対するコマンドにはオプションの引き数があります。
fs プロセスの場合には、各コンポーネント・プロセスごとにローカル・ディスク・バイナリーの完全なパス名を、fileserver、volserver および salvager の順に指定してください。標準のバイナリー・ディレクトリーは、/usr/afs/bin です。初期化コマンドのオプションを使用する場合には、コマンド全体を二重引用符 (" ") で囲んでください。
cron プロセスの場合には、次の 2 つのパラメーターを指定してください。
例
次のコマンドは、マシン fs3.example.com に simple プロセス kaserver を定義し、開始しています。
% bos create -server fs3.example.com -instance kaserver -type simple \
-cmd /usr/afs/bin/kaserver
次のコマンドは、マシン fs4.example.com に simple プロセス upclientbin を定義し、開始しています。このコマンドは、バイナリー・ファイルに対する更新のソースとして、fs1.example.com を参照し、/usr/afs/bin ディレクトリーに対する変更を 120 秒ごとに検査しています。
% bos create -server fs4.example.com -instance upclientbin -type simple \
-cmd "/usr/afs/bin/upclient fs1.example.com -clear -t 120 \
/usr/afs/bin"
次のコマンドは、マシン fs4.example.com に fs プロセス fs を作成しています。このコマンドは、1 行に入力してください。
% bos create -server fs4.example.com -instance fs -type fs \
-cmd /usr/afs/bin/fileserver /usr/afs/bin/volserver \
/usr/afs/bin/salvager
以下のコマンドは、userbackup と呼ばれる cron プロセスを、マシン fs5.example.com 上で作成します。その結果、BOS サーバーは、指示された vos backupsys コマンドを毎日 3:00 a.m. に発行します (このコマンドは、すべてのボリュームのバックアップ・バージョンを、名前が user で始まるファイル・システムに作成します)。 vos コマンドには完全なパス名を指定し、 -localauth フラグ付けて発行してください。また、bos create コマンドは、すべて 1行に入力してください。
% bos create -server fs5.example.com -instance userbackup -type cron \
-cmd "/usr/afs/bin/vos backupsys -prefix user -localauth" 03:00
必要となる特権
コマンドの発行側は、-server 引き数で指定されたマシンの /usr/afs/etc/UserList ファイルにリストされているか、または -localauth フラグが使用されている場合は、ローカル・スーパーユーザー root としてサーバー・マシンにログオンしている必要があります。
関連情報
プロセスの定義と開始を行うためにこのコマンドが使用されるときに、 -notifier 引き数が組み込まれている場合、 BOS サーバーは、プロセスが終了するときに、指示された 通知プログラム を呼び出します。通知プログラムの本来の用途は、プロセスが突然終了したときに、管理者に知らせることですが、それを使用して、任意の適切なアクションを実行することもできます。以下の段落では、BOS サーバーが、終了したプロセスについての情報をレコードしている bnode および bnode_proc 構造体について説明します。これに関連した AFS コマンドのリストも掲げます。
BOS サーバーは、通知プログラムと関連した各終了プロセスに対して、 1 つの bnode および 1 つの bnode_proc 構造体を構成して、標準出力ストリームで送信します。 BOS サーバーは、それぞれの構造体を適切な BEGIN および END ステートメント (BEGIN bnode と END bnode、 BEGIN bnode_proc と END bnode_proc) で囲みます。これは、スペースやほかの文字が介在しない直前の改行文字の直後に続きます。通知プログラムは、構造体からの情報を必要としない場合、 END ステートメントに到達するまで入力ストリームのスキャンを続けます。
一般に、構造体の各フィールドには、改行文字で終了している ASCII テキストの文字列が入っています。構造体内の情報の形式は、通知プログラムと関連したプロセスのタイプ次第で若干変化することがあります。
bnode および bnode_proc 構造体に対する C コードを以下に掲げます。 BOS サーバーによって送信される構造体は、ここで説明するフィールドを必ずしもすべて組み込んでいるわけではないということに注意してください。フィールドのいくつかは、内部レコードの保持のためのみに使用されるからです。通知プロセスは、標準入力ストリーム上の、予期しないフィールドの存在はもちろんのこと、予期されたフィールドの不在も確実に処理しなければなりません。
適切なパフォーマンスのために、通知プログラムは、入力ストリームのプロセッシングを、ファイル終わり (EOF) を検出するまで続けなければなりません。 BOS サーバーは、データの送達を完了すると、通知プロセスに対する標準入力ファイル記述子をクローズします。そして、適切に終了させるのは、通知プロセスの責任です。
struct bnode の内容
struct bnode {
struct bnode *next; /* next pointer in top-level's list */
char *name; /* instance name */
long nextTimeout; /* next time this guy should be awakened */
long period; /* period between calls */
long rsTime; /* time we started counting restarts */
long rsCount; /* count of restarts since rsTime */
struct bnode_type *type; /* type object */
struct bnode_ops *ops; /* functions implementing bnode class */
long procStartTime; /* last time a process was started */
long procStarts; /* number of process starts */
long lastAnyExit; /* last time a process exited for any reason */
long lastErrorExit; /* last time a process exited unexpectedly */
long errorCode; /* last exit return code */
long errorSignal; /* last proc terminating signal */
char *lastErrorName; /* name of proc that failed last */
short refCount; /* reference count */
short flags; /* random flags */
char goal; /* 1=running or 0=not running */
char fileGoal; /* same, but to be stored in file */
};
struct bnode の出力形式
printf("name: %s\n",tp->name);
printf("rsTime: %ld\n", tp->rsTime);
printf("rsCount: %ld\n", tp->rsCount);
printf("procStartTime: %ld\n", tp->procStartTime);
printf("procStarts: %ld\n", tp->procStarts);
printf("lastAnyExit: %ld\n", tp->lastAnyExit);
printf("lastErrorExit: %ld\n", tp->lastErrorExit);
printf("errorCode: %ld\n", tp->errorCode);
printf("errorSignal: %ld\n", tp->errorSignal);
printf("lastErrorName: %s\n", tp->lastErrorName);
printf("goal: %d\n", tp->goal);
struct bnode_proc の内容
struct bnode_proc {
struct bnode_proc *next; /* next guy in top-level's list */
struct bnode *bnode; /* bnode creating this process */
char *comLine; /* command line used to start this process */
char *coreName; /* optional core file component name */
long pid; /* pid if created */
long lastExit; /* last termination code */
long lastSignal; /* last signal that killed this guy */
long flags; /* flags giving process state */
};
struct bnode_proc の出力形式
printf("comLine: %s\n", tp->comLine);
printf("coreName: %s\n", tp->coreName);
printf("pid: %ld\n", tp->pid);
printf("lastExit: %ld\n", tp->lastExit);
printf("lastSignal: %ld\n", tp->lastSignal);