github.com/circular-dark/docker@v1.7.0/contrib/init/upstart/docker.conf (about)

     1  description "Docker daemon"
     2  
     3  start on (local-filesystems and net-device-up IFACE!=lo)
     4  stop on runlevel [!2345]
     5  limit nofile 524288 1048576
     6  limit nproc 524288 1048576
     7  
     8  respawn
     9  
    10  kill timeout 20
    11  
    12  pre-start script
    13  	# see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
    14  	if grep -v '^#' /etc/fstab | grep -q cgroup \
    15  		|| [ ! -e /proc/cgroups ] \
    16  		|| [ ! -d /sys/fs/cgroup ]; then
    17  		exit 0
    18  	fi
    19  	if ! mountpoint -q /sys/fs/cgroup; then
    20  		mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
    21  	fi
    22  	(
    23  		cd /sys/fs/cgroup
    24  		for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do
    25  			mkdir -p $sys
    26  			if ! mountpoint -q $sys; then
    27  				if ! mount -n -t cgroup -o $sys cgroup $sys; then
    28  					rmdir $sys || true
    29  				fi
    30  			fi
    31  		done
    32  	)
    33  end script
    34  
    35  script
    36  	# modify these in /etc/default/$UPSTART_JOB (/etc/default/docker)
    37  	DOCKER=/usr/bin/$UPSTART_JOB
    38  	DOCKER_OPTS=
    39  	if [ -f /etc/default/$UPSTART_JOB ]; then
    40  		. /etc/default/$UPSTART_JOB
    41  	fi
    42  	exec "$DOCKER" -d $DOCKER_OPTS
    43  end script
    44  
    45  # Don't emit "started" event until docker.sock is ready.
    46  # See https://github.com/docker/docker/issues/6647
    47  post-start script
    48  	DOCKER_OPTS=
    49  	if [ -f /etc/default/$UPSTART_JOB ]; then
    50  		. /etc/default/$UPSTART_JOB
    51  	fi
    52  	if ! printf "%s" "$DOCKER_OPTS" | grep -qE -e '-H|--host'; then
    53  		while ! [ -e /var/run/docker.sock ]; do
    54  			initctl status $UPSTART_JOB | grep -qE "(stop|respawn)/" && exit 1
    55  			echo "Waiting for /var/run/docker.sock"
    56  			sleep 0.1
    57  		done
    58  		echo "/var/run/docker.sock is up"
    59  	fi
    60  end script