Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

feature:make cli better #909

Merged
merged 1 commit into from
Sep 30, 2019
Merged

Conversation

yunfeiyanggzq
Copy link
Member

@yunfeiyanggzq yunfeiyanggzq commented Sep 16, 2019

Signed-off-by: yunfeiyangbuaa [email protected]

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

fixes #908

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

Ⅳ. Describe how to verify it

supernode:

yunfeiyang@buaa:~/go/src/github.com/dragonflyoss/Dragonfly/cmd/supernode$ sudo go run main.go -h
Usage:
  Dragonfly Supernode [flags]
  Dragonfly [command]

Available Commands:
  help        Help about any command
  version     Show the current version of supernode

Flags:
      --advertise-ip string             the supernode ip is the ip we advertise to other peers in the p2p-network
      --config string                   the path of supernode's configuration file (default "/etc/dragonfly/supernode.yml")
  -D, --debug                           switch daemon log level to DEBUG mode
      --down-limit int                  download limit for supernode to serve download tasks (default 5)
      --download-path string            download path specifies the path where to store downloaded filed from source address (default "/home/admin/supernode/repo/download")
      --download-port int               downloadPort is the port for download files from supernode (default 8001)
      --fail-access-interval duration   fail access interval is the interval time after failed to access the URL (default 3m0s)
      --gc-initial-delay duration       gc initial delay is the delay time from the start to the first GC execution (default 6s)
      --gc-meta-interval duration       gc meta interval is the interval time to execute the GC meta (default 2m0s)
  -h, --help                            help for Dragonfly
      --home-dir string                 homeDir is the working directory of supernode (default "/home/admin/supernode")
      --max-bandwidth int               max bandwidth is the max network rate that supernode can use (unit: MB/s) (default 200)
      --peer-gc-delay duration          peer gc delay is the delay time to execute the GC after the peer has reported the offline (default 3m0s)
      --pool-size int                   pool size is the core pool size of ScheduledExecutorService (default 10)
      --port int                        listenPort is the port that supernode server listens on (default 8002)
      --profiler                        profiler sets whether supernode HTTP server setups profiler
      --system-bandwidth int            system bandwidth is the network rate reserved for system (unit: MB/s) (default 20)
      --task-expire-time duration       task expire time is the time that a task is treated expired if the task is not accessed within the time (default 3m0s)
      --up-limit int                    upload limit for a peer to serve download tasks (default 5)

Use "Dragonfly [command] --help" for more information about a command.

dfget:

yunfeiyang@buaa:~/go/src/github.com/dragonflyoss/Dragonfly/cmd/dfget$ sudo go run main.go -h
dfget is the client of Dragonfly which takes a role of peer in a P2P network.
When user triggers a file downloading task, dfget will download the pieces of
file from other peers. Meanwhile, it will act as an uploader to support other
peers to download pieces from it if it owns them. In addition, dfget has the
abilities to provide more advanced functionality, such as network bandwidth
limit, transmission encryption and so on.

Usage:
  dfget [flags]
  dfget [command]

Examples:

$ dfget -u https://www.taobao.com -o /tmp/test/b.test --notbs --expiretime 20s
--2019-02-02 18:56:34--  https://www.taobao.com
dfget version:0.3.0
workspace:/root/.small-dragonfly
sign:96414-1549104994.143
client:127.0.0.1 connected to node:127.0.0.1
start download by dragonfly...
download SUCCESS cost:0.026s length:141898 reason:0


Available Commands:
  gen-doc     Generate Document for dfget command line tool with MarkDown format
  help        Help about any command
  server      Launch a peer server for uploading files.
  version     Show the current version of dfget



Flags:
      --alivetime duration    alive duration for which uploader keeps no accessing by any uploading requests, after this period uploader will automatically exit (default 5m0s)
      --cacerts strings       the cacert file which is used to verify remote server when supernode interact with the source.
      --callsystem string     the name of dfget caller which is for debugging. Once set, it will be passed to all components around the request to make debugging easy
      --clientqueue int       specify the size of client queue which controls the number of pieces that can be processed simultaneously (default 6)
      --console               show log on console, it's conflict with '--showbar'
      --dfdaemon              identify whether the request is from dfdaemon
      --expiretime duration   caching duration for which cached file keeps no accessed by any process, after this period cache file will be deleted (default 3m0s)
  -f, --filter string         filter some query params of URL, use char '&' to separate different params
                              eg: -f 'key&sign' will filter 'key' and 'sign' query param
                              in this way, different but actually the same URLs can reuse the same downloading task
      --header strings        http header, eg: --header='Accept: *' --header='Host: abc'
  -h, --help                  help for dfget
  -i, --identifier string     the usage of identifier is making different downloading tasks generate different downloading task IDs even if they have the same URLs. conflict with --md5.
      --insecure              identify whether supernode should skip secure verify when interact with the source.
      --ip string             ip address that server will listen on
  -s, --locallimit string     network bandwidth rate limit for single download task, in format of 20M/m/K/k
  -m, --md5 string            md5 value input from user for the requested downloading file to enhance security
      --minrate string        minimal network bandwidth rate for downloading a file, in format of 20M/m/K/k
  -n, --node strings          specify the addresses(host:port) of supernodes
      --notbs                 disable back source downloading for requested file when p2p fails to download it
  -o, --output string         destination path which is used to store the requested downloading file. It must contain detailed directory and specific filename, for example, '/tmp/file.mp4'
  -p, --pattern string        download pattern, must be p2p/cdn/source, cdn and source do not support flag --totallimit (default "p2p")
      --port int              port number that server will listen on
  -b, --showbar               show progress bar, it is conflict with '--console'
  -e, --timeout int           timeout set for file downloading task. If dfget has not finished downloading all pieces of file before --timeout, the dfget will throw an error and exit
      --totallimit string     network bandwidth rate limit for the whole host, in format of 20M/m/K/k
  -u, --url string            url of user requested downloading file(only HTTP/HTTPs supported)
      --verbose               be verbose

Use "dfget [command] --help" for more information about a command.
yunfeiyang@buaa:~/go/src/github.com/dragonflyoss/Dragonfly/cmd/dfget$ 

Ⅴ. Special notes for reviews

@pouchrobot
Copy link
Collaborator

Thanks for your contribution. 🍻 @yunfeiyanggzq
While we thought PR TITLE could be more specific, longer than 20 chars.
Please edit this PR title instead of opening a new one.
More details, please refer to https://github.com/dragonflyoss/Dragonfly/blob/master/CONTRIBUTING.md

@codecov-io
Copy link

codecov-io commented Sep 16, 2019

Codecov Report

Merging #909 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #909   +/-   ##
=======================================
  Coverage   46.52%   46.52%           
=======================================
  Files         116      116           
  Lines        6901     6901           
=======================================
  Hits         3211     3211           
  Misses       3433     3433           
  Partials      257      257
Impacted Files Coverage Δ
cmd/supernode/app/root.go 55.81% <100%> (ø) ⬆️
cmd/dfget/app/server.go 50% <100%> (ø) ⬆️
cmd/dfget/app/root.go 64.33% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 16169b3...34b2b03. Read the comment docs.

@pouchrobot
Copy link
Collaborator

Thanks for your contribution. 🍻 @yunfeiyanggzq
While we thought PR TITLE could be more specific, longer than 20 chars.
Please edit this PR title instead of opening a new one.
More details, please refer to https://github.com/%!s(MISSING)/%!s(MISSING)/blob/master/CONTRIBUTING.md

@yunfeiyanggzq yunfeiyanggzq changed the title make cli better feature:make cli better Sep 16, 2019
@yunfeiyanggzq yunfeiyanggzq force-pushed the supernode_cli branch 2 times, most recently from d39268c to 21e7b31 Compare September 16, 2019 05:36
@yunfeiyanggzq
Copy link
Member Author

#852

Copy link
Member

@lowzj lowzj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The files in docs/cli_reference are generated automatically. It's unnecessary to modify them manually.

cmd/supernode/app/root_test.go Outdated Show resolved Hide resolved
@yunfeiyanggzq
Copy link
Member Author

The files in docs/cli_reference are generated automatically. It's unnecessary to modify them manually.

get

@@ -193,9 +193,9 @@ func initFlags() {
flagSet := rootCmd.Flags()

// url & output
flagSet.StringVarP(&cfg.URL, "url", "u", "", "URL of user requested downloading file(only HTTP/HTTPs supported)")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Emm...
IMO, URL is a proper noun and it should always be capitalized.
Ref: https://en.wikipedia.org/wiki/URL

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you

cmd/dfget/app/root.go Outdated Show resolved Hide resolved
cmd/dfget/app/server.go Outdated Show resolved Hide resolved
docs/cli_reference/dfget.md Outdated Show resolved Hide resolved
docs/cli_reference/dfget.md Outdated Show resolved Hide resolved
docs/cli_reference/dfget_server.md Outdated Show resolved Hide resolved
@yunfeiyanggzq yunfeiyanggzq force-pushed the supernode_cli branch 3 times, most recently from 9bb70a8 to c9f553e Compare September 18, 2019 09:08
@yunfeiyanggzq
Copy link
Member Author

@starnop Done

@starnop
Copy link
Contributor

starnop commented Sep 19, 2019

LGTM>

Copy link
Member

@SataQiu SataQiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@starnop
Copy link
Contributor

starnop commented Sep 26, 2019

Could you please rebase your code and push it again?

@allencloud
Copy link
Contributor

Any update on this? @yunfeiyanggzq
If you have confirmed to have rebased to the latest master, we can merge this now. Thanks

@yunfeiyanggzq
Copy link
Member Author

Sorry,I ignored the email,I will rebase it today @starnop @allencloud

Signed-off-by: yunfeiyangbuaa <[email protected]>
@yunfeiyanggzq
Copy link
Member Author

done @starnop @allencloud

@starnop starnop merged commit 349313b into dragonflyoss:master Sep 30, 2019
sungjunyoung pushed a commit to sungjunyoung/Dragonfly that referenced this pull request May 8, 2022
* update task access time when task is downloading

Signed-off-by: sunwp <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature]the supernode cli is ugly
7 participants