Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 480866

Summary: sys-apps/openrc-0.11.8 - Custom restart function won't be called
Product: Gentoo Hosted Projects Reporter: Thomas Deutschmann (RETIRED) <whissi>
Component: OpenRCAssignee: OpenRC Team <openrc>
Status: RESOLVED FIXED    
Severity: normal CC: polynomial-c
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 439098    

Description Thomas Deutschmann (RETIRED) gentoo-dev 2013-08-13 10:40:04 UTC
Hi,

see this test runscript:

# cat /etc/init.d/test
#!/sbin/runscript

description="runscript to demonstrate, that a custom restart function won't be called"

start() {
	ebegin "I am starting"
	sleep 3
	eend $?
}

stop() {
	einfo "I am stopping"
	sleep 3
	eend $?
}

restart() {
	ebegin "I am restarting"
	sleep 3
	eend $?
}

Now, execute it:

# /etc/init.d/test start
 * Caching service dependencies ...                 [ ok ]
 * I am starting ...                                [ ok ]
# /etc/init.d/test stop
 * I am stopping                                    [ ok ]
# /etc/init.d/test restart
 * I am starting ...                                [ ok ]
# /etc/init.d/test restart
 * I am stopping                                    [ ok ]
 * I am starting ...                                [ ok ]

I am expecting:

# /etc/init.d/test restart
 * I am restarting ...                              [ ok ]


This is documented in 'man runscript' (restart is listed as custom function, which can (should) be overwritten like start, stop if needed).

This bug prevents me from restarting a daemon through SIGUSR signal/explicit option (/usr/bin/daemin --restart) for example, a major loss of functionality.


# emerge --info
Portage 2.1.13.7 (default/linux/amd64/13.0, gcc-4.7.3, glibc-2.17, 3.10.5 x86_64)
=================================================================
System uname: Linux-3.10.5-x86_64-Intel-R-_Core-TM-_i7-3770K_CPU_@_3.50GHz-with-gentoo-2.2
KiB Mem:     4050772 total,    251176 free
KiB Swap:    1048572 total,   1048572 free
Timestamp of tree: Sun, 11 Aug 2013 13:15:01 +0000
ld GNU ld (GNU Binutils) 2.23.1
app-shells/bash:          4.2_p45
dev-lang/python:          2.7.5-r1, 3.2.5-r1, 3.3.2-r1
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.11.8
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.13.4, 1.14
sys-devel/binutils:       2.23.1
sys-devel/gcc:            4.7.3
sys-devel/gcc-config:     1.8
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.9 (virtual/os-headers)
sys-libs/glibc:           2.17

[...]

ABI="amd64"
ABI_X86="64"
ACCEPT_KEYWORDS="amd64 ~amd64"

[...]

sys-apps/openrc-0.11.8 was built with the following:
USE="(multilib) ncurses pam unicode -debug -newnet (-prefix) (-selinux) -static-libs" ABI_X86="64"
CFLAGS="-O2 -pipe -march=corei7-avx -mno-movbe -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-tbm --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=8192 -mtune=generic"
CXXFLAGS="-O2 -pipe -march=corei7-avx -mno-movbe -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-tbm --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=8192 -mtune=generic"

Reproducible: Always
Comment 1 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2013-08-13 10:44:05 UTC
I can confirm that. Same here.
Comment 2 Alexander Vershilov (RETIRED) gentoo-dev 2013-08-13 11:51:12 UTC
As far as I know custom restart function collides with other deps, so
if you restarting a service it's deps have to stop it's deps. 

So current solution is to use another function 'reload' for example, see 
Will this solution work for you?

We will try to review current state, and see how we can improve situation.
Comment 3 William Hubbs gentoo-dev 2013-08-13 17:34:13 UTC
OpenRc has never allowed you to override the restart function, because
it stops and starts dependencies internally. However, it does allow you
to change your service script's behaviour by testing against the RC_CMD
variable.

if [ "$RC_CMD" = "restart" ]; then
# do what we need to do specially for a restart
fi

If you want something completely different from stop followed by start,
such as sending a signal to a daemon, use a separate command function
like reload.

Commit b2f8ac9 clarifies the runscript man page.
Thanks for the report.