1 |
swift 11/08/12 19:34:56 |
2 |
|
3 |
Modified: hb-working-rcscripts.xml |
4 |
Log: |
5 |
Fix #348724 (documentation part) - Document that restart functionality is not something users can define in the init scripts themselves |
6 |
|
7 |
Revision Changes Path |
8 |
1.33 xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml |
9 |
|
10 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml?rev=1.33&view=markup |
11 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml?rev=1.33&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml?r1=1.32&r2=1.33 |
13 |
|
14 |
Index: hb-working-rcscripts.xml |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml,v |
17 |
retrieving revision 1.32 |
18 |
retrieving revision 1.33 |
19 |
diff -u -r1.32 -r1.33 |
20 |
--- hb-working-rcscripts.xml 2 Mar 2011 08:09:48 -0000 1.32 |
21 |
+++ hb-working-rcscripts.xml 12 Aug 2011 19:34:56 -0000 1.33 |
22 |
@@ -4,7 +4,7 @@ |
23 |
<!-- The content of this document is licensed under the CC-BY-SA license --> |
24 |
<!-- See http://creativecommons.org/licenses/by-sa/2.5 --> |
25 |
|
26 |
-<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml,v 1.32 2011/03/02 08:09:48 nightmorph Exp $ --> |
27 |
+<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml,v 1.33 2011/08/12 19:34:56 swift Exp $ --> |
28 |
|
29 |
<sections> |
30 |
|
31 |
@@ -14,8 +14,8 @@ |
32 |
these aspects and explains how to deal with these scripts. |
33 |
</abstract> |
34 |
|
35 |
-<version>2</version> |
36 |
-<date>2011-03-02</date> |
37 |
+<version>3</version> |
38 |
+<date>2011-08-12</date> |
39 |
|
40 |
<section> |
41 |
<title>Runlevels</title> |
42 |
@@ -440,10 +440,6 @@ |
43 |
stop() { |
44 |
<comment>(Commands necessary to stop the service)</comment> |
45 |
} |
46 |
- |
47 |
-restart() { |
48 |
- <comment>(Commands necessary to restart the service)</comment> |
49 |
-} |
50 |
</pre> |
51 |
|
52 |
<p> |
53 |
@@ -574,6 +570,11 @@ |
54 |
|
55 |
<pre caption="Example start() function"> |
56 |
start() { |
57 |
+ if [ "${RC_CMD}" = "restart" ]; |
58 |
+ then |
59 |
+ <comment># Do something in case a restart requires more than stop, start</comment> |
60 |
+ fi |
61 |
+ |
62 |
ebegin "Starting my_service" |
63 |
start-stop-daemon --start --exec /path/to/my_service \ |
64 |
--pidfile /path/to/my_pidfile |
65 |
@@ -591,6 +592,15 @@ |
66 |
service fails to start. |
67 |
</p> |
68 |
|
69 |
+<p> |
70 |
+Another notable setting used in the above example is to check the contents of |
71 |
+the <c>RC_CMD</c> variable. Unlike the previous init script system, the newer |
72 |
+<c>openrc</c> system does not support script-specific restart functionality. |
73 |
+Instead, the script needs to check the contents of the <c>RC_CMD</c> variable |
74 |
+to see if a function (be it <c>start()</c> or <c>stop()</c>) is called as part |
75 |
+of a restart or not. |
76 |
+</p> |
77 |
+ |
78 |
<note> |
79 |
Make sure that <c>--exec</c> actually calls a service and not just a shell |
80 |
script that launches services and exits -- that's what the init script is |
81 |
@@ -604,14 +614,13 @@ |
82 |
</p> |
83 |
|
84 |
<p> |
85 |
-Other functions you can define are: <c>stop()</c> and <c>restart()</c>. You are |
86 |
-not obliged to define these functions! Our init system is intelligent enough to |
87 |
-fill these functions by itself if you use <c>start-stop-daemon</c>. |
88 |
+Another function you can define is <c>stop()</c>. You are not obliged to define |
89 |
+this function though! Our init system is intelligent enough to fill in this |
90 |
+function by itself if you use <c>start-stop-daemon</c>. |
91 |
</p> |
92 |
|
93 |
<p> |
94 |
-Although you do not <e>have</e> to create a <c>stop()</c> function, here is an |
95 |
-example: |
96 |
+Here is an example of a <c>stop()</c> function: |
97 |
</p> |
98 |
|
99 |
<pre caption="Example stop() function"> |
100 |
@@ -681,6 +690,10 @@ |
101 |
} |
102 |
</pre> |
103 |
|
104 |
+<impo> |
105 |
+The function <c>restart()</c> cannot be overridden in openrc! |
106 |
+</impo> |
107 |
+ |
108 |
</body> |
109 |
</subsection> |
110 |
<subsection> |