Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Adding instruction details
Browse files Browse the repository at this point in the history
  • Loading branch information
emcniece committed Mar 19, 2017
1 parent a732cbf commit b48c704
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 5 deletions.
17 changes: 17 additions & 0 deletions .env-sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Server
export FILESYNC_MODE=server
export FILESYNC_PORT=6776
export FILESYNC_IP=0.0.0.0
export FILESYNC_PATH=/tmp/share

# Client
export FILESYNC_MODE=client
export FILESYNC_PORT=6776
export FILESYNC_IP=127.0.0.1
export FILESYNC_PATH=/tmp/test1

# Cleanup
unset FILESYNC_MODE
unset FILESYNC_PORT
unset FILESYNC_IP
unset FILESYNC_PATH
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ RUN tar -zxvf /tmp/filesync -C /usr/local/bin \
&& mv /usr/local/bin/filesync-linux-amd64 /usr/local/bin/filesync \
&& chmod +x /usr/local/bin/filesync \
&& rm /tmp/filesync
RUN mkdir /share
&& mkdir /share

ENTRYPOINT ["/usr/local/bin/filesync"]
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ go run gsync.go gsync/server.json
go run gsync.go gsync/client.json
```

Alternatively, set environment variables (examples in [/.env](/.env)):
Alternatively, set environment variables (examples in [/.env-sample](/.env-sample)):

```sh
# Server
Expand All @@ -51,6 +51,38 @@ make dev-image
make image
```

## Options

Configuration can be defined by JSON or ENV variables. Priority (from high to low) is JSON config file, ENV variables, then defaults. See the `Init()` method in [vars.go](/vars/vars.go) for details.

### JSON Configuration

Sample:

```
{
"mode": "client",
"ip": "127.0.0.1",
"port": 6776,
"monitors": {
"home_elgs_desktop_a": "/home/elgs/Desktop/c",
"home_elgs_desktop_b": "/home/elgs/Desktop/d"
}
}
```

- `mode`: "client" or "server"
- `ip`: Address or hostname of server
- `port`: Port for traffic
- `monitors`: key-value pairs of directories to watch. The "key" of these gets treated as the unique directory to be synchronized, while the "value" is the file system location for this key.

### ENVironment Variable Configuration

- `FILESYNC_MODE`: "client" or "server"
- `FILESYNC_PORT`
- `FILESYNC_IP`
- `FILESYNC_PATH`: A singular directory to watch. If multiple directories are required, use the JSON config. If not specified, defaults to `/share/`.

## Demo

The [docker-compose.yml](/docker-compose.yml) details a setup with a server and 2 clients. It will create a `./demo/` directory with 3 subfolders: `server`, `client1`, and `client2`. Each subfolder is volumed as `/share/` inside each container.
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
tty: true
stdin_open: true
labels:
io.rancher.scheduler.affinity:host_label: rgon=primary
io.rancher.scheduler.affinity:host_label: filesync=server
environment:
FILESYNC_MODE: 'server'
FILESYNC_PATH: '/share'
Expand All @@ -20,7 +20,7 @@ services:
- fs-server:fs-server
labels:
io.rancher.scheduler.global: 'true'
io.rancher.scheduler.affinity:host_label_ne: rgon=primary
io.rancher.scheduler.affinity:host_label_ne: filesync=server
environment:
FILESYNC_MODE: 'client'
FILESYNC_IP: 'fs-server'
Expand All @@ -35,7 +35,7 @@ services:
- fs-server:fs-server
labels:
io.rancher.scheduler.global: 'true'
io.rancher.scheduler.affinity:host_label_ne: rgon=primary
io.rancher.scheduler.affinity:host_label_ne: filesync=server
environment:
FILESYNC_MODE: 'client'
FILESYNC_IP: 'fs-server'
Expand Down

0 comments on commit b48c704

Please sign in to comment.