6

カスタム Amazon AMI (Fedora) を作成しました。いくつかのスクリプトを実行してからシャットダウンします。

AMI の問題は、コードが変更された場合、AMI インスタンスが最新のスクリプトを実行する前に取得する方法が必要になることです。

シェルスクリプトを書いて入れました/etc/init.d/nt_startup

コードを最新の状態に保つためgit pullに、コード リポジトリでシェル スクリプトを実行してから、スクリプトを実行します。

問題は、git pullインスタンスの起動時に が実行されていないように見えることですが、Python スクリプトは問題なく実行されます。何が欠けているのかわからない...起動スクリプトは次のとおりです。

#!/bin/bash
#
# ec2 Startup script for EC2 machines
#
# chkconfig: 345 99 02
# description: Script used to issue startup and shutdown commands.
#

if [ "$1" = "start" ]; then
 /usr/scripts/code/git_latest
 python /usr/scripts/code/process.py
 exit
fi

if [ "$1" = "stop" ]; then
#nothing
exit
fi

シェル スクリプトは次の/usr/scripts/code/git_latestようになります。

#pulls in the latest code from the repository
cd /usr/scripts/code
sudo git pull

process.py最新のスクリプトをプルダウンする必要があります。

奇妙なことに、インスタンスに ssh 接続して起動スクリプトを手動で実行すると ( /etc/init.d/nt_startup "start")、git スクリプトは問題なく動作します。

何か不足していますか?

4

2 に答える 2

0

/etc/rc?.d に起動リンクを配置する必要があります。これらのディレクトリを管理するには、chkconfig(8) または ntsysv(8) を使用できます。

于 2009-02-13T18:42:33.983 に答える