<commit_before>// Copyright 2014 The roc Author. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.


package rocserv

import (
    "github.com/julienschmidt/httprouter"

	//"github.com/shawnfeng/sutil/slog"
	//"github.com/shawnfeng/sutil/snetutil"

)

type backDoorHttp struct {}

func (m *backDoorHttp) Init() error {
	return nil
}

func (m *backDoorHttp) Driver() (string, interface{}) {
	//fun := "backDoorHttp.Driver -->"

    router := httprouter.New()

	return "", router

}
<commit_msg>backdoor add restart interface<commit_after>// Copyright 2014 The roc Author. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.


package rocserv

import (
	"os"
    "github.com/julienschmidt/httprouter"

	"github.com/shawnfeng/sutil/slog"
	"github.com/shawnfeng/sutil/snetutil"

)

type backDoorHttp struct {}

func (m *backDoorHttp) Init() error {
	return nil
}

func (m *backDoorHttp) Driver() (string, interface{}) {
	//fun := "backDoorHttp.Driver -->"

    router := httprouter.New()
	// 重启
    router.POST("/restart", snetutil.HttpRequestWrapper(FactoryRestart))

	return "", router

}



// ==============================
type Restart struct {

}

func FactoryRestart() snetutil.HandleRequest {
	return new(Restart)
}

func (m *Restart) Handle(r *snetutil.HttpRequest) snetutil.HttpResponse {

	slog.Infof("RECEIVE RESTART COMMAND")
	os.Exit(0)
	// 这里的代码执行不到了，因为之前已经退出了
	return snetutil.NewHttpRespString(200, "{}")
}


{'fraction_non_alphanumeric': 0.14659018483110262, 'fraction_numerical': 0.0076481835564053535, 'mean_word_length': 3.9371069182389937, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7427793', 'n_tokens_mistral': 581, 'n_tokens_neox': 560, 'n_words': 140}