Installation and Executation ============================== Installation ------------- Clone source code ++++++++++++++++++ Please make sure you have Go installed on your system. If you don't know what it is, please check :ref:`go-env`. .. code-block:: bash $ mkdir -p ${GOPATH}/src/github.com/swiftstack $ cd ${GOPATH}/src/github.com/swiftstack $ git clone https://github.com/swiftstack/go-watch-folder Install packages and run tests ++++++++++++++++++++++++++++++++++++ Please install the ``automake`` package on your system to make sure you can use ``make`` command. .. code-block:: bash $ make prepare go get -u github.com/sanbornm/go-selfupdate/... go get -u github.com/jteeuwen/go-bindata/... go get -u github.com/golang/dep/cmd/dep dep ensure $ make test ### Unit tests for GoWF ### Usage of /var/folders/6g/9slv6z496gn6q8n0vmhdlvbh0000gn/T/go-build594409299/b001/gowf.test: . . . INFO: 2018/07/03 16:14:44 watch.go:133: Checker-0 (/Users/charles/gowork/src/github.com/swiftstack/go-watch-folder/gowf/testdata/dummyswift.conf): /private/tmp/dummy (0 files are shuffled) DEBUG: 2018/07/03 16:14:44 stats.go:57: Local: 0 files DEBUG: 2018/07/03 16:14:44 stats.go:58: Remote: 0 objects DEBUG: 2018/07/03 16:14:44 stats.go:59: Trigger jobs: 0 by User, 0 by GoWF DEBUG: 2018/07/03 16:14:44 stats.go:60: Jobs in queue: 0 objects DEBUG: 2018/07/03 16:14:44 stats.go:61: Jobs in progress: 0 SLOs, 0 objects, 0 MD5 calculation DEBUG: 2018/07/03 16:14:44 stats.go:63: Jobs uploaded: 0 successes, 0 failures, 0 disregard type: %!s(bool=true) type: %!s(bool=true) --- PASS: TestRunWatchFolderTask (3.01s) PASS coverage: 46.7% of statements ok github.com/swiftstack/go-watch-folder/gowf (cached) coverage: 46.7% of statements . . . === RUN TestCompareDeduperHasAnchor Dedup: 2018/07/03 16:15:08 deduper_test.go:75: Alloc = 102503 KiB, TotalAlloc = 4935966 KiB, Sys = 2067266 KiB, NumGC = 36 KiB 2018/07/03 16:15:10 TestCompareDeduperNonStreaming took 1.472720069s Dedup: 2018/07/03 16:15:10 deduper_test.go:75: Alloc = 196539 KiB, TotalAlloc = 5459877 KiB, Sys = 2067266 KiB, NumGC = 50 KiB Dedup: 2018/07/03 16:15:10 deduper_test.go:75: Alloc = 100 KiB, TotalAlloc = 5459877 KiB, Sys = 2067266 KiB, NumGC = 51 KiB delete random write file /tmp/100MB --- PASS: TestCompareDeduperHasAnchor (1.96s) PASS coverage: 94.9% of statements ok github.com/swiftstack/go-watch-folder/dedup (cached) coverage: 94.9% of statements Build binary ++++++++++++++++++ .. code-block:: bash $ make binary go-bindata -pkg main -o cmd/templates.go tmpl/*.html GOOS=linux GOARCH=amd64 go build -ldflags "-w -s -X main.Version=0.0.8-25-g4ea76d6 -X main.UpgradeServer=https://cloud.swiftstack.com/v1/AUTH_gowfdev/" -o build/gowf.linux cmd/gowf.go You can find binaries in ``build`` folder .. code-block:: bash $ tree ${GOPATH}/src/github.com/swiftstack/go-watch-folder/build /Users/charles/gowork/src/github.com/swiftstack/go-watch-folder/build └── gowf.linux 0 directories, 1 files Execution ------------- In GoWF, a single configuration file is used to connect to a Swift account to which you will upload objects into containers in a specified Swift account. Therefore, if you want to map folders to different Swift accounts, you need to provide multiple configuration files to GoWF. .. _command-line-exec: Command line ++++++++++++++++++ Single configuration file ^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: bash $ gowf --config gowf.conf # run it in debug mode (turn on log-level to debug) $ gowf --config gowf.conf --log-file log.txt --log-level DEBUG # run it in debug mode $ gowf --config gowf.conf \ --log-file log.txt \ --log-level DEBUG Multiple Configuration Files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: bash $ gowf --config gowf.conf --config gowf-2nd.conf List Containers or Objects under Container ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: bash # list container base on your default gowf configuration file # Using default /etc/gowf/gowf.conf for listing swift containers $ gowf --list # Using specific gowf.conf for listing swift containers $ gowf --config gowf.conf --list # Using default /etc/gowf/gowf.conf for listing swift objects under swift container $ gowf --list # Using specific gowf.conf for listing swift containers for listing swift objects under swift container $ gowf --config gowf.conf --list # Using --log-level DEBUG to get more details $ gowf --list --log-level DEBUG Download Object ^^^^^^^^^^^^^^^ .. code-block:: bash # Download swift object base on your default gowf configuration file (/etc/gowf/gowf.conf) $ gowf --download # If you don't give , it will download to "object name" in current folder $ gowf --download # Using specific gowf.conf for downloading swift object $ gowf --config gowf.conf --download # If you don't give , it will download to "object name" in current folder $ gowf --config gowf.conf --download Systemd service ++++++++++++++++++ Single Configuration file ^^^^^^^^^^^^^^^^^^^^^^^^^^ If you use the standard install script to install GoWF, you will automatically install the latest version. You can find the configuration file in ``/etc/gowf/gowf.conf``. .. code-block:: bash $ sudo systemctl start gowf.service $ sudo systemctl stop gowf.service $ sudo systemctl status gowf.service Multiple Configuration Files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ By default, the systemd service file provided only uses a single configuration file. If you want to support multiple Swift accounts, please modify ``/etc/systemd/system/gowf.service`` and add ``--config `` .. code-block:: bash ExecStart=/usr/bin/gowf --config /etc/gowf/gowf.conf --log-file /var/log/gowf/gowf.log --stats-folder /var/log/gowf/stats/ to .. code-block:: bash ExecStart=/usr/bin/gowf --config /etc/gowf/gowf.conf --config /etc/gowf/another-gowf.conf --log-file /var/log/gowf/gowf.log After modifying the systemd file and restart gowf. .. code-block:: bash $ sudo systemctl restart gowf.service $ sudo systemctl status gowf.service