-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offline daemon mode #2696
Offline daemon mode #2696
Conversation
@@ -136,6 +137,7 @@ future version, along with this notice. Please move to setting the HTTP Headers. | |||
cmds.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)"), | |||
cmds.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection"), | |||
cmds.BoolOption(adjustFDLimitKwd, "Check and raise file descriptor limits if needed"), | |||
cmds.BoolOption(offlineKwd, "Run in offline. Do not connect with rest of the network but provide local API.").Default(false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it also still provide the gateway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it does. Finalizing sharness tests for it.
@@ -416,6 +419,10 @@ func serveHTTPApi(req cmds.Request) (error, <-chan error) { | |||
|
|||
// printSwarmAddrs prints the addresses of the host | |||
func printSwarmAddrs(node *core.IpfsNode) { | |||
if !node.OnlineMode() { | |||
fmt.Print("Swarm not listening, running in offline mode.\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i prefer using fmt.Println
and omitting the trailing newline from the string
6c817de
to
e400df0
Compare
we probably want to add a few more tests for various bits of the functionality. maybe at the end of |
Good that you requested this test as problem looks harder that it was. |
Yey, tests are passing. Awaiting review, if it is successful I will squash everything later. |
@@ -136,6 +137,7 @@ future version, along with this notice. Please move to setting the HTTP Headers. | |||
cmds.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)").Default(false), | |||
cmds.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection").Default(false), | |||
cmds.BoolOption(adjustFDLimitKwd, "Check and raise file descriptor limits if needed").Default(false), | |||
cmds.BoolOption(offlineKwd, "Run offline. Do not connect with rest of the network but provide local API.").Default(false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RichardLitt I don't know if the wording is good and clear enough, it would be great if you could take a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Run offline. Do not connect to the rest of the network, but provide only the local API." 👍
Resolves #2393 License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
08d26e3
to
3a89cbb
Compare
I think it might be worth introducing separate mode of operation as currently |
@@ -136,6 +137,7 @@ future version, along with this notice. Please move to setting the HTTP Headers. | |||
cmds.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)").Default(false), | |||
cmds.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection").Default(false), | |||
cmds.BoolOption(adjustFDLimitKwd, "Check and raise file descriptor limits if needed").Default(false), | |||
cmds.BoolOption(offlineKwd, "Run offline. Do not connect to the rest of the network but provide local API.").Default(false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provide the local API, maybe?
It makes me quite happy how small these changes are. This LGTM, thanks! |
They are small but were pain to get right. 😄 |
Great work @Kubuxu 🎉 |
@@ -159,7 +159,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request | |||
} | |||
|
|||
nd, err := core.Resolve(ctx, i.node, path.Path(urlPath)) | |||
if err != nil { | |||
// If node is in offline mode the error code and message should be different | |||
if err == core.ErrNoNamesys && !i.node.OnlineMode() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think there's other errors here to check alongside !i.node.OnlineMode()
. for example, if a /ipfs/...
path fails to resolve, it's likely because of no network.
👍 great to have offline mode |
Offline daemon mode This commit was moved from ipfs/kubo@6a894d6
Resolves #2393