[Lxc-users] shutting down CentOS6 container

Milos Negovanovic milos.negovanovic at gmail.com
Mon Oct 17 20:26:08 UTC 2011


On Mon, Oct 17, 2011 at 10:12:18PM +0200, Papp Tamas wrote:
> kill -INT init
> 
> I use this diff on ubuntu host:
> 
> --- lxc.orig    2011-10-16 22:59:24.186322805 +0200
> +++ lxc    2011-10-17 22:10:17.974920307 +0200
> @@ -52,6 +52,37 @@
>     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
> +    if ! is_running $name;then
> +        log_failure_msg "$name is not running."
> +    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
> @@ -80,7 +111,8 @@
>       ;;
>     stop)
>       log_daemon_msg "Stopping $DESC"
> -    action_all "lxc-stop -n"
> +    #action_all "lxc-stop -n"
> +    action_all stop_one
>       ;;
>     restart|force-reload)
>       log_daemon_msg "Restarting $DESC"
> 
> 
> tamas
> 

If I am not mistaken thats similar approach to using this script:

http://pastie.org/2713689

Ive tried using that python script, but instead of shutting down my
container restarts! Can you paste your container /etc/inittab by any
chance?

Regards
-- 
Milos Negovanovic
milos.negovanovic at gmail.com




More information about the lxc-users mailing list