Allow core/command in remote control continue running

Hi everyone,

I'm making a wrapper for rclone now, and I've encountered an limitation of rclone : a command submit via remote control API can't run after the HTTP connection closed.

Could it be possible to let the command run in background, and make client fetch repose later? We can give each request to core/command an unique number as identifier. After a command started, rclone send the identifier back and client can use the identifier to fetch result or terminate it.

This will make dynamic adjusting rclone serve possible, and considering that HTTP is not suitable to streaming terminal output, I think this change will make the remote control API useful under more situations.

I think this is what you are asking?

https://rclone.org/rc/#running-asynchronous-jobs-with-async-true

Thank you for your response! I tried this but rclone crashed:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x56466bab9af8]

goroutine 78 [running]:
bufio.(*Writer).Flush(0x56466d10e580)
        /usr/lib64/go/1.17/src/bufio/bufio.go:601 +0x18
net/http.(*chunkWriter).flush(0x56466e12f4c0)
        /usr/lib64/go/1.17/src/net/http/server.go:397 +0x3f
net/http.(*response).ReadFrom(0xc0008e2620, {0x56466d3f9a00, 0xc0005168d0})
        /usr/lib64/go/1.17/src/net/http/server.go:593 +0x276
io.copyBuffer({0x56466d3f98a0, 0xc0008e2620}, {0x56466d3f9a00, 0xc0005168d0}, {0x0, 0x0, 0x0})
        /usr/lib64/go/1.17/src/io/io.go:409 +0x14b
io.Copy(...)
        /usr/lib64/go/1.17/src/io/io.go:382
os/exec.(*Cmd).writerDescriptor.func1()
        /usr/lib64/go/1.17/src/os/exec/exec.go:311 +0x3a
os/exec.(*Cmd).Start.func1(0xc000532450)
        /usr/lib64/go/1.17/src/os/exec/exec.go:441 +0x25
created by os/exec.(*Cmd).Start

I have no idea what version, what you ran, etc.

So what you tried is a mystery to me..

Sorry for missing information.

I'm running rclone v1.57.0 from github release.

> ./rclone version
rclone v1.57.0
- os/version: opensuse-tumbleweed (64 bit)
- os/kernel: 5.15.2-1-default (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.17.2
- go/linking: static
- go/tags: none

I started the remote control server using following command:

['./rclone', 'rcd', '--cache-dir=/tmp/rclone-ctl', 
'--rc-addr=localhost:5572', '--rc-user=tux', '--rc-pass=uF5WJWfg']

I send it this:

{
    "command": "serve",
    "arg": [
        "webdav",
        "--user=tux",
        "--pass=uF5WJWfg",
        "--addr=localhost:19090",
        "od-bc:"
    ],
    "returnType": "STREAM",
    "_async": true
}

and I got this from http response:

{
        "jobid": 2
}

And then it crashed.

There isn't a serve command.

Where did you find that command?

I know that there's no remote serve command, but I just thought I can have a workaround with core/command ...

I don't think that's a use case for that with serve as there is an open issue to address it over rc.

You can follow the issue I shared.

I got it. Thank you.

and to be sure:

@ncw - can confirm as I've been wrong before and I'm sure I'll be wrong again :slight_smile:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.