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

Commit b48c704

Browse files
committed
Adding instruction details
1 parent a732cbf commit b48c704

File tree

4 files changed

+54
-5
lines changed

4 files changed

+54
-5
lines changed

.env-sample

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Server
2+
export FILESYNC_MODE=server
3+
export FILESYNC_PORT=6776
4+
export FILESYNC_IP=0.0.0.0
5+
export FILESYNC_PATH=/tmp/share
6+
7+
# Client
8+
export FILESYNC_MODE=client
9+
export FILESYNC_PORT=6776
10+
export FILESYNC_IP=127.0.0.1
11+
export FILESYNC_PATH=/tmp/test1
12+
13+
# Cleanup
14+
unset FILESYNC_MODE
15+
unset FILESYNC_PORT
16+
unset FILESYNC_IP
17+
unset FILESYNC_PATH

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ RUN tar -zxvf /tmp/filesync -C /usr/local/bin \
88
&& mv /usr/local/bin/filesync-linux-amd64 /usr/local/bin/filesync \
99
&& chmod +x /usr/local/bin/filesync \
1010
&& rm /tmp/filesync
11-
RUN mkdir /share
11+
&& mkdir /share
1212

1313
ENTRYPOINT ["/usr/local/bin/filesync"]

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ go run gsync.go gsync/server.json
2626
go run gsync.go gsync/client.json
2727
```
2828

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

3131
```sh
3232
# Server
@@ -51,6 +51,38 @@ make dev-image
5151
make image
5252
```
5353

54+
## Options
55+
56+
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.
57+
58+
### JSON Configuration
59+
60+
Sample:
61+
62+
```
63+
{
64+
"mode": "client",
65+
"ip": "127.0.0.1",
66+
"port": 6776,
67+
"monitors": {
68+
"home_elgs_desktop_a": "/home/elgs/Desktop/c",
69+
"home_elgs_desktop_b": "/home/elgs/Desktop/d"
70+
}
71+
}
72+
```
73+
74+
- `mode`: "client" or "server"
75+
- `ip`: Address or hostname of server
76+
- `port`: Port for traffic
77+
- `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.
78+
79+
### ENVironment Variable Configuration
80+
81+
- `FILESYNC_MODE`: "client" or "server"
82+
- `FILESYNC_PORT`
83+
- `FILESYNC_IP`
84+
- `FILESYNC_PATH`: A singular directory to watch. If multiple directories are required, use the JSON config. If not specified, defaults to `/share/`.
85+
5486
## Demo
5587

5688
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.

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
tty: true
77
stdin_open: true
88
labels:
9-
io.rancher.scheduler.affinity:host_label: rgon=primary
9+
io.rancher.scheduler.affinity:host_label: filesync=server
1010
environment:
1111
FILESYNC_MODE: 'server'
1212
FILESYNC_PATH: '/share'
@@ -20,7 +20,7 @@ services:
2020
- fs-server:fs-server
2121
labels:
2222
io.rancher.scheduler.global: 'true'
23-
io.rancher.scheduler.affinity:host_label_ne: rgon=primary
23+
io.rancher.scheduler.affinity:host_label_ne: filesync=server
2424
environment:
2525
FILESYNC_MODE: 'client'
2626
FILESYNC_IP: 'fs-server'
@@ -35,7 +35,7 @@ services:
3535
- fs-server:fs-server
3636
labels:
3737
io.rancher.scheduler.global: 'true'
38-
io.rancher.scheduler.affinity:host_label_ne: rgon=primary
38+
io.rancher.scheduler.affinity:host_label_ne: filesync=server
3939
environment:
4040
FILESYNC_MODE: 'client'
4141
FILESYNC_IP: 'fs-server'

0 commit comments

Comments
 (0)