rc: new call rc/pid - closes #2211

This commit is contained in:
Michael P. Dubner 2018-04-05 17:12:34 +03:00 committed by Nick Craig-Wood
parent 05e32cfcf9
commit 92b266d361
2 changed files with 25 additions and 1 deletions

View file

@ -118,6 +118,11 @@ check that parameter passing is working properly.
This returns an error with the input as part of its error string.
Useful for testing error handling.
### rc/pid: Return PID of current process
This returns PID of current process.
Useful for stopping rclone process.
### rc/list: List all the registered remote control commands
This lists all the registered remote control commands as a JSON map in

View file

@ -2,7 +2,11 @@
package rc
import "github.com/pkg/errors"
import (
"os"
"github.com/pkg/errors"
)
func init() {
Add(Call{
@ -30,6 +34,14 @@ Useful for testing error handling.`,
This lists all the registered remote control commands as a JSON map in
the commands response.`,
})
Add(Call{
Path: "rc/pid",
Fn: rcPid,
Title: "Return PID of current process",
Help: `
This returns PID of current process.
Useful for stopping rclone process.`,
})
}
// Echo the input to the ouput parameters
@ -48,3 +60,10 @@ func rcList(in Params) (out Params, err error) {
out["commands"] = registry.list()
return out, nil
}
// Return PID of current process
func rcPid(in Params) (out Params, err error) {
out = make(Params)
out["pid"] = os.Getpid()
return out, nil
}