カスタム 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 スクリプトは問題なく動作します。
何か不足していますか?