Skip to content
This repository was archived by the owner on Mar 26, 2020. It is now read-only.

Commit 51e7ddc

Browse files
authored
Merge pull request #582 from aravindavk/systemd_service
Default configuration for glusterd2 when run using `systemctl`
2 parents b5f8705 + ae0fe1b commit 51e7ddc

20 files changed

+62
-55
lines changed

doc/quick-start-user-guide.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,29 @@ $ mkdir -p /var/lib/gd2
5151
```
5252

5353
**Create a config file:** This is optional but if your VM/machine has multiple network interfaces, it is recommended to create a config file. The config file location can be passed to Glusterd2 using the `--config` option.
54-
Glusterd2 will also pick up conf files named `glusterd.{yaml|json|toml}` if available in `/etc/glusterd2/` or the current directory.
55-
56-
```yaml
57-
$ cat conf.yaml
58-
workdir: "/var/lib/gd2"
59-
peeraddress: "192.168.56.101:24008"
60-
clientaddress: "192.168.56.101:24007"
61-
etcdcurls: "http://192.168.56.101:2379"
62-
etcdpurls: "http://192.168.56.101:2380"
54+
Glusterd2 will also pick up conf file named `glusterd2.toml` if available in `/etc/glusterd2/` or the current directory.
55+
56+
```toml
57+
$ cat conf.toml
58+
workdir = "/var/lib/gd2"
59+
peeraddress = "192.168.56.101:24008"
60+
clientaddress = "192.168.56.101:24007"
61+
etcdcurls = "http://192.168.56.101:2379"
62+
etcdpurls = "http://192.168.56.101:2380"
6363
```
6464

6565
Replace the IP address accordingly on each node.
6666

6767
**Start glusterd2 process:** Glusterd2 is not a daemon and currently can run only in the foreground.
6868

6969
```sh
70-
# ./glusterd2 --config conf.yaml
70+
# ./glusterd2 --config conf.toml
7171
```
7272

7373
You will see an output similar to the following:
7474
```log
7575
INFO[2017-08-28T16:03:58+05:30] Starting GlusterD pid=1650
76-
INFO[2017-08-28T16:03:58+05:30] loaded configuration from file file=conf.yaml
76+
INFO[2017-08-28T16:03:58+05:30] loaded configuration from file file=conf.toml
7777
INFO[2017-08-28T16:03:58+05:30] Generated new UUID uuid=19db62df-799b-47f1-80e4-0f5400896e05
7878
INFO[2017-08-28T16:03:58+05:30] started muxsrv listener
7979
INFO[2017-08-28T16:03:58+05:30] Started GlusterD ReST server ip:port=192.168.56.101:24007

e2e/config/1.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
workdir = "/tmp/gd2_func_test/w1"
2+
logfile = "w1.log"
3+
peeraddress = "127.0.0.1:24008"
4+
clientaddress = "127.0.0.1:24007"
5+
etcdcurls = "http://127.0.0.1:2479"
6+
etcdpurls = "http://127.0.0.1:2480"

e2e/config/1.yaml

-6
This file was deleted.

e2e/config/2.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
workdir = "/tmp/gd2_func_test/w2"
2+
logfile = "w2.log"
3+
peeraddress = "127.0.0.1:23008"
4+
clientaddress = "127.0.0.1:23007"
5+
etcdcurls = "http://127.0.0.1:2379"
6+
etcdpurls = "http://127.0.0.1:2380"

e2e/config/2.yaml

-6
This file was deleted.

e2e/config/3.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
workdir = "/tmp/gd2_func_test/w3"
2+
logfile = "w3.log"
3+
peeraddress = "127.0.0.1:22008"
4+
clientaddress = "127.0.0.1:22007"
5+
etcdcurls = "http://127.0.0.1:2279"
6+
etcdpurls = "http://127.0.0.1:2280"

e2e/config/3.yaml

-6
This file was deleted.

e2e/config/4.toml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
workdir = "/tmp/gd2_func_test/w4"
2+
logfile = "w4.log"
3+
peeraddress = "127.0.0.1:21008"
4+
clientaddress = "127.0.0.1:21007"
5+
etcdcurls = "http://127.0.0.1:2179"
6+
etcdpurls = "http://127.0.0.1:2180"
7+
restauth = true

e2e/config/4.yaml

-7
This file was deleted.

e2e/georep_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
func TestGeorepCreateDelete(t *testing.T) {
1414
r := require.New(t)
1515

16-
gds, err := setupCluster("./config/1.yaml", "./config/2.yaml")
16+
gds, err := setupCluster("./config/1.toml", "./config/2.toml")
1717
r.Nil(err)
1818
defer teardownCluster(gds)
1919

e2e/glustershd_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TestGlusterShd(t *testing.T) {
1313

1414
r := require.New(t)
1515

16-
gds, err := setupCluster("./config/1.yaml", "./config/2.yaml")
16+
gds, err := setupCluster("./config/1.toml", "./config/2.toml")
1717
r.Nil(err)
1818
defer teardownCluster(gds)
1919

e2e/peer_ops_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ import (
1010
func TestAddRemovePeer(t *testing.T) {
1111
r := require.New(t)
1212

13-
g1, err := spawnGlusterd("./config/1.yaml", true)
13+
g1, err := spawnGlusterd("./config/1.toml", true)
1414
r.Nil(err)
1515
defer g1.Stop()
1616
defer g1.EraseWorkdir()
1717
r.True(g1.IsRunning())
1818

19-
g2, err := spawnGlusterd("./config/2.yaml", true)
19+
g2, err := spawnGlusterd("./config/2.toml", true)
2020
r.Nil(err)
2121
defer g2.Stop()
2222
defer g2.EraseWorkdir()
2323
r.True(g2.IsRunning())
2424

25-
g3, err := spawnGlusterd("./config/3.yaml", true)
25+
g3, err := spawnGlusterd("./config/3.toml", true)
2626
r.Nil(err)
2727
defer g3.Stop()
2828
defer g3.EraseWorkdir()

e2e/quota_enable.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func testQuotaEnable(t *testing.T) {
1616
var err error
1717
r := require.New(t)
1818

19-
gds, err := setupCluster("./config/1.yaml", "./config/2.yaml")
19+
gds, err := setupCluster("./config/1.toml", "./config/2.toml")
2020
r.Nil(err)
2121
defer teardownCluster(gds)
2222

e2e/restapi_auth_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
func TestRESTAPIAuth(t *testing.T) {
1313
r := require.New(t)
1414

15-
g1, err := spawnGlusterd("./config/4.yaml", true)
15+
g1, err := spawnGlusterd("./config/4.toml", true)
1616
r.Nil(err)
1717
defer g1.Stop()
1818
defer g1.EraseWorkdir()

e2e/restart_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
func TestRestart(t *testing.T) {
1414
r := require.New(t)
1515

16-
gd, err := spawnGlusterd("./config/1.yaml", true)
16+
gd, err := spawnGlusterd("./config/1.toml", true)
1717
r.Nil(err)
1818
r.True(gd.IsRunning())
1919

@@ -42,7 +42,7 @@ func TestRestart(t *testing.T) {
4242

4343
r.Nil(gd.Stop())
4444

45-
gd, err = spawnGlusterd("./config/1.yaml", false)
45+
gd, err = spawnGlusterd("./config/1.toml", false)
4646
r.Nil(err)
4747
r.True(gd.IsRunning())
4848

e2e/utils_test.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ import (
1515

1616
"github.com/gluster/glusterd2/pkg/api"
1717
"github.com/gluster/glusterd2/pkg/restclient"
18-
"gopkg.in/yaml.v2"
18+
19+
toml "github.com/pelletier/go-toml"
1920
)
2021

2122
type gdProcess struct {
2223
Cmd *exec.Cmd
23-
ClientAddress string `yaml:"clientaddress"`
24-
PeerAddress string `yaml:"peeraddress"`
25-
Workdir string `yaml:"workdir"`
24+
ClientAddress string `toml:"clientaddress"`
25+
PeerAddress string `toml:"peeraddress"`
26+
Workdir string `toml:"workdir"`
2627
uuid string
2728
}
2829

@@ -98,7 +99,7 @@ func spawnGlusterd(configFilePath string, cleanStart bool) (*gdProcess, error) {
9899
}
99100

100101
g := gdProcess{}
101-
if err = yaml.Unmarshal(fContent, &g); err != nil {
102+
if err = toml.Unmarshal(fContent, &g); err != nil {
102103
return nil, err
103104
}
104105

e2e/volume_ops_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestVolume(t *testing.T) {
3131

3232
r := require.New(t)
3333

34-
gds, err = setupCluster("./config/1.yaml", "./config/2.yaml")
34+
gds, err = setupCluster("./config/1.toml", "./config/2.toml")
3535
r.Nil(err)
3636
defer teardownCluster(gds)
3737

@@ -192,7 +192,7 @@ func TestVolumeOptions(t *testing.T) {
192192

193193
r := require.New(t)
194194

195-
gds, err := setupCluster("./config/1.yaml")
195+
gds, err := setupCluster("./config/1.toml")
196196
r.Nil(err)
197197
defer teardownCluster(gds)
198198

extras/systemd/glusterd2.service

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Before=network-online.target
66
Conflicts=glusterd.service
77

88
[Service]
9-
ExecStart=/usr/sbin/glusterd2
9+
ExecStart=/usr/sbin/glusterd2 --config=/etc/glusterd2/glusterd2.toml
1010
KillMode=process
1111

1212
[Install]

glusterd2/config.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func parseFlags() {
4444
flag.String("workdir", "", "Working directory for GlusterD. (default: current directory)")
4545
flag.String("localstatedir", "", "Directory to store local state information. (default: workdir)")
4646
flag.String("rundir", "", "Directory to store runtime data. (default: workdir/run)")
47-
flag.String("config", "", "Configuration file for GlusterD. By default looks for glusterd2.(yaml|toml|json) in [/usr/local]/etc/glusterd2 and current working directory.")
47+
flag.String("config", "", "Configuration file for GlusterD. By default looks for glusterd2.toml in [/usr/local]/etc/glusterd2 and current working directory.")
4848

4949
flag.String(logging.DirFlag, "", logging.DirHelp+" (default: workdir/log)")
5050
flag.String(logging.FileFlag, "STDOUT", logging.FileHelp)
@@ -135,6 +135,9 @@ func initConfig(confFile string) error {
135135
// If a config file was given, read in configration from that file.
136136
// If the file is not present panic.
137137

138+
// Limit config to toml only to avoid confusion with multiple config types
139+
config.SetConfigType("toml")
140+
138141
if confFile == "" {
139142
config.SetConfigName(defaultConfName)
140143
for _, p := range defaultConfPaths {
@@ -148,7 +151,7 @@ func initConfig(confFile string) error {
148151
if confFile == "" {
149152
log.WithFields(log.Fields{
150153
"paths": defaultConfPaths,
151-
"config": defaultConfName + ".(toml|yaml|json)",
154+
"config": defaultConfName + ".toml",
152155
"error": err,
153156
}).Debug("failed to read any config files, continuing with defaults")
154157
} else {

scripts/gen-gd2conf.sh

+3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ PREFIX=${PREFIX:-/usr/local}
44
DATADIR=${DATADIR:-$PREFIX/share}
55
LOCALSTATEDIR=${LOCALSTATEDIR:-$PREFIX/var/lib}
66
LOGDIR=${LOGDIR:-$PREFIX/var/log}
7+
RUNDIR=${RUNDIR:-$PREFIX/var/run}
78

89
GD2="glusterd2"
910
GD2STATEDIR=${GD2STATEDIR:-$LOCALSTATEDIR/$GD2}
1011
GD2LOGDIR=${GD2LOGDIR:-$LOGDIR/$GD2}
12+
GD2RUNDIR=${GD2RUNDIR:-$RUNDIR/$GD2}
1113

1214
OUTDIR=${1:-build}
1315
mkdir -p $OUTDIR
@@ -19,4 +21,5 @@ cat >$OUTPUT <<EOF
1921
localstatedir = "$GD2STATEDIR"
2022
logdir = "$GD2LOGDIR"
2123
logfile = "$GD2.log"
24+
rundir = "$GD2RUNDIR"
2225
EOF

0 commit comments

Comments
 (0)