From 7f4cdb25357dda17257fcb353e90293118b7f6af Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Thu, 23 Jul 2015 22:37:56 -0700 Subject: [PATCH 1/2] server: support config flag --- server/main.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/main.go b/server/main.go index 3cfb53a..312a876 100644 --- a/server/main.go +++ b/server/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "io/ioutil" "net" @@ -13,15 +14,17 @@ import ( ) func main() { - configfn := "default.conf" - data, err := ioutil.ReadFile(configfn) + configfn := flag.String("config", "default.conf", "location of configuration file") + flag.Parse() + + data, err := ioutil.ReadFile(*configfn) if err != nil { - log.Fatalf("server: cannot load configuration file[%s] (%v)", configfn, err) + log.Fatalf("server: cannot load configuration file[%s] (%v)", *configfn, err) } var conf config.Server if _, err := toml.Decode(string(data), &conf); err != nil { - log.Fatalf("server: configuration file[%s] is not valid (%v)", configfn, err) + log.Fatalf("server: configuration file[%s] is not valid (%v)", *configfn, err) } // default is that cfs is bootstrapped using docker From e1479c20701511c3c1421be847d8e7f25e998275 Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Thu, 23 Jul 2015 22:41:38 -0700 Subject: [PATCH 2/2] hack/docker-cluster: add fast way to start local docker cluster This displays the way to run multiple cfs fast in docker. And this helps for further development on reconstruct and copy. --- .gitignore | 1 + hack/docker-cluster/Procfile | 5 +++++ hack/docker-cluster/cleanup.sh | 4 ++++ hack/docker-cluster/config/cfs0.conf | 24 ++++++++++++++++++++++++ hack/docker-cluster/config/cfs1.conf | 24 ++++++++++++++++++++++++ hack/docker-cluster/config/cfs2.conf | 24 ++++++++++++++++++++++++ 6 files changed, 82 insertions(+) create mode 100644 hack/docker-cluster/Procfile create mode 100755 hack/docker-cluster/cleanup.sh create mode 100644 hack/docker-cluster/config/cfs0.conf create mode 100644 hack/docker-cluster/config/cfs1.conf create mode 100644 hack/docker-cluster/config/cfs2.conf diff --git a/.gitignore b/.gitignore index 90e4130..acace69 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ _testmain.go /server/server /server/cfs0000 /cfsctl/cfsctl +/hack/docker-cluster/cfs* # temporary build path /proto/gopath diff --git a/hack/docker-cluster/Procfile b/hack/docker-cluster/Procfile new file mode 100644 index 0000000..4b9a75b --- /dev/null +++ b/hack/docker-cluster/Procfile @@ -0,0 +1,5 @@ +# Use goreman to run: +# `go get github.com/mattn/goreman` +cfs0: docker run --volume=/:/rootfs:ro --volume=/var/run:/var/run:rw --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --volume=/tmp:/tmp:rw --volume=${PWD}/cfs0_0:/cfs0_0 --volume=${PWD}/cfs0_1:/cfs0_1 --volume=${PWD}/config:/config --publish=5000:15524 -i --name=cfs0 c-fs/cfs --config=/config/cfs0.conf +cfs1: docker run --volume=/:/rootfs:ro --volume=/var/run:/var/run:rw --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --volume=/tmp:/tmp:rw --volume=${PWD}/cfs1_0:/cfs1_0 --volume=${PWD}/cfs1_1:/cfs1_1 --volume=${PWD}/config:/config --publish=5001:15524 -i --name=cfs1 c-fs/cfs --config=/config/cfs1.conf +cfs2: docker run --volume=/:/rootfs:ro --volume=/var/run:/var/run:rw --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --volume=/tmp:/tmp:rw --volume=${PWD}/cfs2_0:/cfs2_0 --volume=${PWD}/cfs2_1:/cfs2_1 --volume=${PWD}/config:/config --publish=5002:15524 -i --name=cfs2 c-fs/cfs --config=/config/cfs2.conf diff --git a/hack/docker-cluster/cleanup.sh b/hack/docker-cluster/cleanup.sh new file mode 100755 index 0000000..19ea4f5 --- /dev/null +++ b/hack/docker-cluster/cleanup.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker stop $(docker ps -a -q) +docker rm $(docker ps -a -q) diff --git a/hack/docker-cluster/config/cfs0.conf b/hack/docker-cluster/config/cfs0.conf new file mode 100644 index 0000000..d3d99c2 --- /dev/null +++ b/hack/docker-cluster/config/cfs0.conf @@ -0,0 +1,24 @@ +# Default Configuration in TOML + +################################ GENERAL ##################################### + +# Accept connections on the specified port, default is 15524. +port = "15524" + +# By default cfs listens for connections from all the network interfaces +# available on the server. +# +# Examples: +# +# bind = "127.0.0.1" + + +################################ DISKS ####################################### + +[[Disks]] +name = "cfs0_0" +root = "cfs0_0" + +[[Disks]] +name = "cfs0_1" +root = "cfs0_1" diff --git a/hack/docker-cluster/config/cfs1.conf b/hack/docker-cluster/config/cfs1.conf new file mode 100644 index 0000000..b02857b --- /dev/null +++ b/hack/docker-cluster/config/cfs1.conf @@ -0,0 +1,24 @@ +# Default Configuration in TOML + +################################ GENERAL ##################################### + +# Accept connections on the specified port, default is 15524. +port = "15524" + +# By default cfs listens for connections from all the network interfaces +# available on the server. +# +# Examples: +# +# bind = "127.0.0.1" + + +################################ DISKS ####################################### + +[[Disks]] +name = "cfs1_0" +root = "cfs1_0" + +[[Disks]] +name = "cfs1_1" +root = "cfs1_1" diff --git a/hack/docker-cluster/config/cfs2.conf b/hack/docker-cluster/config/cfs2.conf new file mode 100644 index 0000000..61c25a9 --- /dev/null +++ b/hack/docker-cluster/config/cfs2.conf @@ -0,0 +1,24 @@ +# Default Configuration in TOML + +################################ GENERAL ##################################### + +# Accept connections on the specified port, default is 15524. +port = "15524" + +# By default cfs listens for connections from all the network interfaces +# available on the server. +# +# Examples: +# +# bind = "127.0.0.1" + + +################################ DISKS ####################################### + +[[Disks]] +name = "cfs2_0" +root = "cfs2_0" + +[[Disks]] +name = "cfs2_1" +root = "cfs2_1"