added coredump file to debian init command

This commit is contained in:
Radu Ioan Fericean
2014-11-27 15:37:31 +02:00
parent 98d3bd6cde
commit d0fb4aab90
2 changed files with 4 additions and 28 deletions

View File

@@ -22,10 +22,8 @@ import (
"errors"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"runtime"
//"runtime"
"strconv"
"time"
@@ -304,22 +302,7 @@ func writePid() {
}
}
func start() {
defer func() {
if r := recover(); r != nil {
engine.Logger.Crit(fmt.Sprintf("CRITICAL ERROR: %v", r))
var stack [8192]byte
runtime.Stack(stack[:], false)
if tmpFile, err := ioutil.TempFile(os.TempDir(), "cgr_coredump"); err != nil {
engine.Logger.Crit(fmt.Sprintf("Cannot create coredump file: %v", err))
engine.Logger.Crit(string(stack[:]))
} else {
tmpFile.Write(stack[:])
tmpFile.Close()
engine.Logger.Crit(fmt.Sprintf("Core dumped: %s", tmpFile.Name()))
}
}
}()
func main() {
flag.Parse()
if *version {
fmt.Println("CGRateS " + utils.VERSION)
@@ -529,12 +512,3 @@ func start() {
}
engine.Logger.Info("Stopped all components. CGRateS shutdown!")
}
func main() {
defer func() {
if e := recover(); e != nil {
fmt.Fprintf(os.Stderr, "PANIC: %v\n", e)
}
}()
start()
}

View File

@@ -23,6 +23,7 @@ GROUP=cgrates
ENGINE_OPTS=""
RUNDIR=/var/run/$NAME
PIDFILE=$RUNDIR/cgr-engine.pid
COREDUMP=$RUNDIR/cgr-coredump.log
SCRIPTNAME=/etc/init.d/$NAME
DEFAULTS=/etc/default/$NAME
ENABLE=false
@@ -62,7 +63,8 @@ do_start()
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
echo "Started at:" `date`>>$COREDUMP
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null 2>>$COREDUMP \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --exec $DAEMON --chuid $USER:$GROUP --background -- \
$ENGINE_OPTS \