Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autoradio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ale
autoradio
Commits
7e551437
Commit
7e551437
authored
10 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
minor logging fixes
parent
353e1579
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
node/icecast.go
+1
-1
1 addition, 1 deletion
node/icecast.go
node/node.go
+15
-16
15 additions, 16 deletions
node/node.go
with
16 additions
and
17 deletions
node/icecast.go
+
1
−
1
View file @
7e551437
...
...
@@ -110,7 +110,7 @@ func (ic *IcecastController) statusUpdater() {
ic
.
status
=
status
icecastOk
.
Set
(
1
)
}
else
{
log
.
Printf
(
"
bad status from iceast
: %v"
,
err
)
log
.
Printf
(
"
error checking iceast status
: %v"
,
err
)
ic
.
status
=
downStatus
icecastOk
.
Set
(
0
)
}
...
...
This diff is collapsed.
Click to expand it.
node/node.go
+
15
−
16
View file @
7e551437
...
...
@@ -104,6 +104,17 @@ func (w *ConfigSyncer) setIndex(index uint64) {
configIndex
.
Set
(
int64
(
index
))
}
func
(
w
*
ConfigSyncer
)
updateConfigWithResponse
(
index
uint64
,
key
,
value
string
)
{
mountName
:=
keyToMount
(
key
)
log
.
Printf
(
"updating mount %s [@%d]: %s"
,
mountName
,
index
,
value
)
var
m
autoradio
.
Mount
if
err
:=
json
.
NewDecoder
(
strings
.
NewReader
(
value
))
.
Decode
(
&
m
);
err
!=
nil
{
log
.
Printf
(
"corrupted data: %s: %s"
,
value
,
err
)
}
else
{
w
.
config
.
setMount
(
&
m
)
}
}
func
(
w
*
ConfigSyncer
)
syncer
(
ch
chan
*
etcd
.
Response
)
{
for
{
select
{
...
...
@@ -124,7 +135,7 @@ func (w *ConfigSyncer) syncer(ch chan *etcd.Response) {
log
.
Printf
(
"deleted mount %s"
,
mountName
)
w
.
config
.
delMount
(
mountName
)
}
else
if
response
.
Action
==
"set"
||
response
.
Action
==
"create"
||
response
.
Action
==
"update"
{
w
.
updateConfigWithResponse
(
response
.
Node
.
Key
,
response
.
Node
.
Value
)
w
.
updateConfigWithResponse
(
response
.
EtcdIndex
,
response
.
Node
.
Key
,
response
.
Node
.
Value
)
}
else
{
continue
}
...
...
@@ -138,17 +149,6 @@ func (w *ConfigSyncer) syncer(ch chan *etcd.Response) {
}
}
func
(
w
*
ConfigSyncer
)
updateConfigWithResponse
(
key
,
value
string
)
{
mountName
:=
keyToMount
(
key
)
log
.
Printf
(
"updating mount %s: %s"
,
mountName
,
value
)
var
m
autoradio
.
Mount
if
err
:=
json
.
NewDecoder
(
strings
.
NewReader
(
value
))
.
Decode
(
&
m
);
err
!=
nil
{
log
.
Printf
(
"corrupted data: %s: %s"
,
value
,
err
)
}
else
{
w
.
config
.
setMount
(
&
m
)
}
}
// Load full configuration from etcd. This will trigger the update channel.
func
(
w
*
ConfigSyncer
)
loadFullConfig
()
{
for
{
...
...
@@ -156,8 +156,9 @@ func (w *ConfigSyncer) loadFullConfig() {
if
err
==
nil
&&
response
.
Node
!=
nil
&&
response
.
Node
.
Dir
{
// Directly update the configuration.
for
_
,
n
:=
range
response
.
Node
.
Nodes
{
w
.
updateConfigWithResponse
(
n
.
Key
,
n
.
Value
)
w
.
updateConfigWithResponse
(
response
.
EtcdIndex
,
n
.
Key
,
n
.
Value
)
}
log
.
Printf
(
"got configuration at index %d"
,
response
.
EtcdIndex
)
w
.
setIndex
(
response
.
EtcdIndex
)
break
}
...
...
@@ -172,7 +173,6 @@ func (w *ConfigSyncer) loadFullConfig() {
}
// Update the icecast daemon now that we have a full config.
log
.
Printf
(
"triggering initial reload"
)
trigger
(
w
.
upch
)
}
...
...
@@ -181,13 +181,12 @@ func (w *ConfigSyncer) loadFullConfig() {
// in-memory configuration has already been fully synchronized.
func
(
w
*
ConfigSyncer
)
Start
()
{
// Run until the first successful Get().
log
.
Printf
(
"
attempting to
retriev
e
initial config"
)
log
.
Printf
(
"retriev
ing
initial config"
)
w
.
loadFullConfig
()
// Main watch loop. Remember that etcd.Watch() will close the
// receiver channel when it returns, so we need to start a new
// syncer every time.
log
.
Printf
(
"starting config syncer"
)
go
func
()
{
for
{
ch
:=
make
(
chan
*
etcd
.
Response
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment