go-ipfs-cmds icon indicating copy to clipboard operation
go-ipfs-cmds copied to clipboard

Log requests from the CLI

Open schomatis opened this issue 6 years ago • 3 comments

Currently requests are only being logged in the online mode by the HTTP handler. It would be useful to extend this mechanism to cover any IPFS use case, which means logging it also in the offline mode in the CLI.

Normally this wouldn't be necessary as the request log is only used as an informative service where there can be more than one request simultaneously (i.e., in the online mode handling many concurrent HTTP request and not in the offline mode with the CLI handling an only request before shutting down) but the rationale is to have a single point of control for any requests (one or many) before shutting down the IPFS core.

schomatis avatar May 07 '18 18:05 schomatis

I'm having some trouble with the gx workflow (see https://github.com/whyrusleeping/gx/issues/174) so I'm labeling this as blocked until I gain a better understanding of it.

schomatis avatar May 08 '18 15:05 schomatis

@schomatis Sorry for only responding now.

I'm not sure, but there may be a misunderstanding here. IPFS can call it's commands either directly from the cli, or send it to the daemon via http. Note that this has nothing to do with online or offline mode. Online/Offline mode is a property of your running daemon, and specifies whether or not your ipfs node talks to other ipfs nodes. A daemon in offline mode will still track your requests, since they come in through the http api. When a requests is executed directly through the cli, tracking the requests doesn't make much sense because there is just that one requests that is handled by the process.

Also note that IIUC the request log is only kept in memory, and only as long as the daemon is running. Since in the cli case (i.e. when there is no daemon) there is no process in the background that could track requests, all of this would need to be restructured.

keks avatar May 14 '18 11:05 keks

@keks Thanks for the clarification in the terminology.

When a requests is executed directly through the cli, tracking the requests doesn't make much sense because there is just that one requests that is handled by the process.

Yes but @whyrusleeping suggested using the request log as an indication of command termination (even if it is the only one) to avoid shutting down the node prematurely and wait for the command.

Since in the cli case (i.e. when there is no daemon) there is no process in the background that could track requests, all of this would need to be restructured.

This is a good point, I'll have to look deeper into the code. The log request is still created in the CLI case but I haven't found an easy way to check if a request logged in the CLI executor is actually being logged, since the ipfs diag cmds command can only run on the IPFS daemon.

schomatis avatar May 14 '18 15:05 schomatis