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
fe540cd2
Commit
fe540cd2
authored
10 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
improve debugging for the icecast controller
parent
7e551437
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
node/icecast.go
+19
-21
19 additions, 21 deletions
node/icecast.go
with
19 additions
and
21 deletions
node/icecast.go
+
19
−
21
View file @
fe540cd2
...
...
@@ -3,6 +3,7 @@ package node
import
(
"encoding/xml"
"errors"
"fmt"
"io"
"log"
"net/http"
...
...
@@ -16,7 +17,9 @@ import (
)
var
(
statusPageUrl
=
"http://localhost:8000/status-autoradio.xsl"
statusPage
=
"/status-autoradio.xsl"
icecastConfigFile
=
"/etc/icecast2/icecast.xml"
icecastReloadCmd
=
"/usr/sbin/service icecast2 reload || /usr/sbin/service icecast2 start"
icecastOk
=
instrumentation
.
NewGauge
(
"icecast.ok"
)
)
...
...
@@ -48,31 +51,26 @@ type IcecastStatus struct {
}
type
IcecastController
struct
{
PublicIp
string
ConfigFile
string
InitScript
string
config
*
icecastConfig
status
*
IcecastStatus
stop
chan
bool
config
*
icecastConfig
status
*
IcecastStatus
stop
chan
bool
}
func
NewIcecastController
(
publicIp
string
,
stop
chan
bool
)
*
IcecastController
{
return
&
IcecastController
{
PublicIp
:
publicIp
,
ConfigFile
:
"/etc/icecast2/icecast.xml"
,
InitScript
:
"/etc/init.d/icecast2"
,
config
:
newIcecastConfig
(
publicIp
),
status
:
&
IcecastStatus
{},
stop
:
make
(
chan
bool
,
1
),
config
:
newIcecastConfig
(
publicIp
),
status
:
&
IcecastStatus
{},
stop
:
make
(
chan
bool
,
1
),
}
}
// Reload the icecast daemon. Redirects output to our standard error
// for debugging purposes.
func
(
ic
*
IcecastController
)
reload
()
error
{
err
:=
exec
.
Command
(
ic
.
InitScript
,
"reload"
)
.
Run
()
if
err
!=
nil
{
err
=
exec
.
Command
(
ic
.
InitScript
,
"start"
)
.
Run
()
}
return
err
cmd
:=
exec
.
Command
(
"/bin/sh"
,
"-c"
,
icecastReloadCmd
)
cmd
.
Stdout
=
os
.
Stderr
cmd
.
Stderr
=
os
.
Stderr
return
cmd
.
Run
()
}
// Update reloads the Icecast daemon with a new configuration.
...
...
@@ -81,7 +79,7 @@ func (ic *IcecastController) Update(conf *ClusterConfig, isMaster bool, masterAd
return
errors
.
New
(
"unknown system state"
)
}
tmpf
:=
ic
.
ConfigFile
+
".tmp"
tmpf
:=
ic
ecast
ConfigFile
+
".tmp"
defer
os
.
Remove
(
tmpf
)
ic
.
config
.
Update
(
conf
,
isMaster
,
masterAddr
)
...
...
@@ -89,7 +87,7 @@ func (ic *IcecastController) Update(conf *ClusterConfig, isMaster bool, masterAd
return
err
}
if
err
:=
os
.
Rename
(
tmpf
,
ic
.
ConfigFile
);
err
!=
nil
{
if
err
:=
os
.
Rename
(
tmpf
,
ic
ecast
ConfigFile
);
err
!=
nil
{
return
err
}
...
...
@@ -121,7 +119,7 @@ func (ic *IcecastController) statusUpdater() {
}
func
(
ic
*
IcecastController
)
fetchStatus
()
(
*
IcecastStatus
,
error
)
{
resp
,
err
:=
http
.
Get
(
statusPage
Url
)
resp
,
err
:=
http
.
Get
(
fmt
.
Sprintf
(
"http://localhost:%d%s"
,
autoradio
.
IcecastPort
,
statusPage
)
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
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