Codebase list centreon-engine / b3ca441
Add debug into sysv start up script. Dorian Guillois 11 years ago
1 changed file(s) with 24 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
2727 user=@USER@
2828 group=@GROUP@
2929 timeout=300
30 debug=0
3031
3132 servicename=$(basename "$0")
3233 command="$1"
6566 fi
6667 fi
6768
68 check_configuration()
69 {
69 check_configuration() {
7070 # Check if we can find the configuration file.
7171 if [ ! -r $config_file ]; then
7272 log_failure_msg "$servicename: configuration file $config_file not found: $command request failed"
8080 fi
8181 }
8282
83 service_start()
84 {
83 service_start() {
8584 if [ -f $pid_file ] && [ ! -d "/proc/$(cat $pid_file)" ]; then
8685 rm -f $pid_file > /dev/null 2>&1
8786 fi
9190
9291 su - $user -c "touch $var_dir/centengine.log $retention_file"
9392
94 su - $user -c "$binary $config_file > /dev/null 2>&1 &"
93 if [ $debug -eq 1 ]; then
94 echo "/tmp/%e.core.%t.%u.%p" > /proc/sys/kernel/core_pattern
95 su - $user -c "ulimit -c unlimited; $binary $config_file >> $var_dir/init.debug 2>&1 &"
96 else
97 su - $user -c "$binary $config_file > /dev/null 2>&1 &"
98 fi
99
95100 sleep 2
96 pid=$(pidofproc $binary)
97 if [ $? -ne 0 ]; then
101 pid=$(pidofproc $binary)
102 if [ $? -ne 0 ]; then
98103 log_failure_msg "$servicename $command: failed."
99104 exit 1
100105 fi
101106 echo $pid > $pid_file
102
103107 touch $lock_file;
104 fi
105 }
106
107 service_stop()
108 {
108
109 if [ $debug -eq 1 ]; then
110 su - $user -c "echo pid=$pid >> $var_dir/init.debug"
111 # strace -fF -p $pid 2>&1 >> "$var_dir/init.debug" &
112 fi
113 fi
114 }
115
116 service_stop() {
109117 pid=$(pidofproc $binary)
110118 if [ $? -eq 0 ]; then
111119 kill $pid
127135 rm -f $lock_file $command_file $pid_file
128136 }
129137
130 service_reload()
131 {
138 service_reload() {
132139 check_configuration
133140 pid=$(pidofproc $binary)
134141 if [ $? -ne 0 ]; then
138145 kill -HUP $pid
139146 }
140147
141 service_force_reload()
142 {
148 service_force_reload() {
143149 check_configuration
144150 pid=$(pidofproc $binary)
145151 if [ $? -ne 0 ]; then
149155 fi
150156 }
151157
152 service_status()
153 {
158 service_status() {
154159 pidofproc $binary > /dev/null 2>&1
155160 if [ $? -eq 0 ]; then
156161 log_success_msg "$servicename $command: running"