func (r *AbstractRuntime) Stop() error {
	r.Logger.WarnWith("Stopping",
		"status", r.GetStatus(),
		"wrapperProcess", r.wrapperProcess)
	if r.wrapperProcess != nil {
		if err := r.processWaiter.Cancel(); err != nil {
			r.Logger.WarnWith("Failed to cancel process waiting")
		}
		r.Logger.WarnWith("Killing wrapper process", "wrapperProcessPid", r.wrapperProcess.Pid)
		if err := r.wrapperProcess.Kill(); err != nil {
			r.SetStatus(status.Error)
			return errors.Wrap(err, "Can't kill wrapper process")
		}
	}
	r.waitForProcessTermination()
	r.wrapperProcess = nil
	r.SetStatus(status.Stopped)
	r.Logger.Warn("Successfully stopped wrapper process")
	return nil
}
Stop stops the runtime
package rpc
import (
	"bufio"
	"encoding/base64"
	"encoding/json"
	"fmt"
	"io"
	"net"
	"net/http"
	"os"
	"time"
	"github.com/nuclio/nuclio/pkg/common"
	"github.com/nuclio/nuclio/pkg/common/status"
	"github.com/nuclio/nuclio/pkg/processor/runtime"
	"github.com/nuclio/nuclio/pkg/processwaiter"
	"github.com/nuclio/errors"
	"github.com/nuclio/logger"
	"github.com/nuclio/nuclio-sdk-go"
	"github.com/rs/xid"
)
const (
	socketPathTemplate = "/tmp/nuclio-rpc-%s.sock"
	connectionTimeout  = 2 * time.Minute
)
type result struct {
	StatusCode   int                    `json:"status_code"`
	ContentType  string                 `json:"content_type"`
	Body         string                 `json:"body"`
	BodyEncoding string                 `json:"body_encoding"`
	Headers      map[string]interface{} `json:"headers"`
	DecodedBody []byte
	err         error
}
type AbstractRuntime struct {
	runtime.AbstractRuntime
	configuration  *runtime.Configuration
	eventEncoder   EventEncoder
	wrapperProcess *os.Process
	resultChan     chan *result
	functionLogger logger.Logger
	runtime        Runtime
	startChan      chan struct{}
	stopChan       chan struct{}
	socketType     SocketType
	processWaiter  *processwaiter.ProcessWaiter
}
type rpcLogRecord struct {
	DateTime string                 `json:"datetime"`
	Level    string                 `json:"level"`
	Message  string                 `json:"message"`
	With     map[string]interface{} `json:"with"`
}
func NewAbstractRuntime(logger logger.Logger,
	configuration *runtime.Configuration,
	runtimeInstance Runtime) (*AbstractRuntime, error) {
	var err error
	abstractRuntime, err := runtime.NewAbstractRuntime(logger, configuration)
	if err != nil {
		return nil, errors.Wrap(err, "Can't create AbstractRuntime")
	}
	newRuntime := &AbstractRuntime{
		AbstractRuntime: *abstractRuntime,
		configuration:   configuration,
		runtime:         runtimeInstance,
		startChan:       make(chan struct{}, 1),
		stopChan:        make(chan struct{}, 1),
		socketType:      UnixSocket,
	}
	return newRuntime, nil
}
func (r *AbstractRuntime) Start() error {
	if err := r.startWrapper(); err != nil {
		r.SetStatus(status.Error)
		return errors.Wrap(err, "Failed to run wrapper")
	}
	r.SetStatus(status.Ready)
	return nil
}
func (r *AbstractRuntime) ProcessEvent(event nuclio.Event, functionLogger logger.Logger) (interface{}, error) {
	if currentStatus := r.GetStatus(); currentStatus != status.Ready {
		return nil, errors.Errorf("Processor not ready (current status: %s)", currentStatus)
	}
	r.functionLogger = functionLogger
	if err := r.eventEncoder.Encode(event); err != nil {
		r.functionLogger = nil
		return nil, errors.Wrapf(err, "Can't encode event: %+v", event)
	}
	result, ok := <-r.resultChan
	r.functionLogger = nil
	if !ok {
		msg := "Client disconnected"
		r.Logger.Error(msg)
		r.SetStatus(status.Error)
		r.functionLogger = nil
		return nil, errors.New(msg)
	}
	return nuclio.Response{
		Body:        result.DecodedBody,
		ContentType: result.ContentType,
		Headers:     result.Headers,
		StatusCode:  result.StatusCode,
	}, nil
}