Amazon WebServices で EC2 インスタンスを起動しました。また、/ etc/init.dフォルダーにshutdownSocketServerというサービスを作成しました。シャットダウンと再起動時に呼び出されるようにします。
に追加しchkconfig -add
、で定義されていることを確認しました
sudo chkconfig --list | grep shutdownSocketServer
shutdownSocketServer 0:on 1:off 2:off 3:off 4:off 5:off 6:on
スクリプトは次のとおりです。
#!/bin/bash
# chkconfig: 06 001 001
# description: Foo server
. /etc/init.d/functions
sudo touch /var/lock/subsys/shutdownSocketServer
start(){
EC2_INSTANCE_ID="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id || die \"wget instance-id has failed: $?\"`"
echo "$EC2_INSTANCE_ID"
curl "http://mywebservice.com/Server/functions/SocketUpdater.php? estado=shutdown&instance_id=$EC2_INSTANCE_ID"
}
stop(){
echo "stopping"
}
### main logic ###
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart|reload|condrestart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
だから私の問題は、EC2がシャットダウンしているときにネットワークにアクセスできないと思うことです。どうすればそれを回避できますか?どうすれば確認できますか?