Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 310511 | Differences between
and this patch

Collapse All | Expand All

(-)a/preload (-23 / +38 lines)
Lines 1-5 Link Here
1
#!/sbin/runscript
1
#!/sbin/runscript
2
2
3
description='Start/stop the preload daemon'
4
extra_started_commands='dump reload'
5
description_dump='Dump the config and state of the daemon (to the logfile)'
6
description_reload='Reload the daemon'
7
3
PIDFILE="/var/run/preload.pid"
8
PIDFILE="/var/run/preload.pid"
4
9
5
depend() {
10
depend() {
Lines 8-50 depend() { Link Here
8
}
13
}
9
14
10
dump() {
15
dump() {
11
	ebegin "Dumping config and state for preload"
16
	local pid
12
	kill -USR1 $(<${PIDFILE})
17
	pid=$(cat ${PIDFILE})
13
	kill -USR2 $(<${PIDFILE})
18
14
	eend $?
19
	ebegin "Dumping the config and state of preload"
20
	if [ -n "${pid}" ]; then
21
		kill -USR1 ${pid}
22
		kill -USR2 ${pid}
23
	fi
24
	eend ${?} && \
25
	einfo "These should have been written to ${PRELOAD_LOGFILE:-/var/log/preload.log}"
15
}
26
}
16
27
17
reload() {
28
reload() {
18
	ebegin "Reloading preload"
29
	ebegin "Reloading preload"
19
	kill -HUP $(<${PIDFILE})
30
	kill -HUP $(cat ${PIDFILE})
20
	eend $?
31
	eend ${?}
21
}
32
}
22
33
23
start() {
34
start() {
35
	local ionice
36
24
	ebegin "Starting preload"
37
	ebegin "Starting preload"
25
38
26
	#MIN_MEMORY=${MIN_MEMORY:-256}
39
	#MIN_MEMORY=${MIN_MEMORY:-256}
27
	# Check for > MIN_MEMORY MB
40
	# Check for > MIN_MEMORY MB
28
	#free -m | awk '/Mem:/ {exit ($2 >= ('"$MIN_MEMORY"'))?0:1}' || exit 0
41
	#free -m | awk '/Mem:/ {exit ($2 >= ('"$MIN_MEMORY"'))?0:1}' || exit 0
29
42
30
	# IMPORTANT: Let ssd do the backgrounding so we immediatly get a valid
43
	# First try to start with ionice; if that fails, try without.
31
	# pid file in the next step (ionice)
44
	for ionice in "ionice ${IONICE_OPTS:--c3}" ''; do
32
	start-stop-daemon --start --quiet --background \
45
		# Avoid 'ionice not found' errors
33
		--make-pidfile --pidfile ${PIDFILE} \
46
		${ionice:-true} >/dev/null 2>&1 || continue
34
		--exec /usr/sbin/preload -- \
47
35
		-l ${PRELOAD_LOGFILE:-/var/log/preload.log} -V ${PRELOAD_VERBOSITY:-1} \
48
		${ionice} start-stop-daemon --start --quiet --background \
36
		-n ${PRELOAD_NICE:-15} -s ${PRELOAD_STATEFILE:-""} ${PRELOAD_OPTS} -f
49
			--make-pidfile --pidfile ${PIDFILE} \
37
50
			--exec /usr/sbin/preload -- \
38
	IONICE=$(which ionice)
51
			-l ${PRELOAD_LOGFILE:-/var/log/preload.log} \
39
	if [ -x "$IONICE" ]; then
52
			-V ${PRELOAD_VERBOSITY:-1} \
40
		IONICE_OPTS=${IONICE_OPTS:--c3}
53
			-n ${PRELOAD_NICE:-15} \
41
		$IONICE ${IONICE_OPTS} -p$(<${PIDFILE})
54
			-s ${PRELOAD_STATEFILE:-""} \
42
	fi
55
			${PRELOAD_OPTS} -f \
43
	eend $?
56
			&& break
57
	done
58
59
	eend ${?}
44
}
60
}
45
61
46
stop() {
62
stop() {
47
	ebegin "Stopping preload (this may take while)"
63
	ebegin "Stopping preload (this may take a while)"
48
	start-stop-daemon --stop --retry 120 --quiet --pidfile ${PIDFILE}
64
	start-stop-daemon --stop --retry 120 --quiet --pidfile ${PIDFILE}
49
	eend $?
65
	eend ${?}
50
}
66
}
51
- 

Return to bug 310511