我在 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 关闭时网络无法访问。怎么能避免呢?我怎样才能检查它?