On 09/02/2011 06:33 PM, Matteo Bernardini wrote: > 2011/9/2 Papp Tamas<tom...@martos.bme.hu>: >> What is the right way to stop a container? > hope this lxc-devel's thread can help > > http://sourceforge.net/mailarchive/forum.php?thread_name=4DDA6AD2.3070900%40thomas-krenn.com&forum_name=lxc-devel > > personally, I have no problem in ssh'ing in the container and halt it. :)
Thanks. Would not the init script be better with this diff at least until lxc-attach gets to work? --- lxc.orig 2011-01-27 15:07:41.000000000 +0100 +++ lxc 2011-09-04 18:09:32.300937844 +0200 @@ -37,6 +37,34 @@ fi } +stop_one() { + name=$1 + dir_cgroup=`grep -w cgroup /proc/mounts|awk '{ print $2 }'` + if [ ! -d $dir_cgroup/$name ]; then + log_failure_msg "$name is not running." + return + fi + + echo -n "Stopping $name" + pid_init=`lxc-ps --name $name | grep init$ | awk '{ print $2 }'` + + kill -INT $pid_init + count=0 + while lxc-ps --name $name | egrep -qv '(init$|CONTAINER PID TTY TIME CMD)';do + if [ $count -ge 600 ];then + log_failure_msg "Container $name cannot be stopped on the proper way." + return + fi + echo -n '.'; + sleep 1; + count=$(($count+1)) + done + + lxc-stop -n $name + echo " done." + log_success_msg "Container $name has been stopped successfully." +} + action_all() { action=$1 nolog=$2 @@ -54,7 +82,8 @@ ;; stop) log_daemon_msg "Stopping $DESC" - action_all "lxc-stop -n" + action_all stop_one ;; restart|force-reload) log_daemon_msg "Restarting $DESC" Modified from Ubuntu's script: ii lxc 0.7.4-0ubuntu9 Linux containers userspace tools I'm sorry about my poor scripting skills:) Thanks, tamas ------------------------------------------------------------------------------ Special Offer -- Download ArcSight Logger for FREE! Finally, a world-class log management solution at an even better price-free! And you'll get a free "Love Thy Logs" t-shirt when you download Logger. Secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsisghtdev2dev _______________________________________________ Lxc-users mailing list Lxc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-users