Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sfu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alain Takoudjou
sfu
Commits
f5cb2ff3
Commit
f5cb2ff3
authored
Sep 18, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework synchronisation between webserver and main.
We now exit with an error code if the webserver couldn't start.
parent
aeb8540a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
14 deletions
+25
-14
sfu.go
sfu.go
+15
-3
webserver/webserver.go
webserver/webserver.go
+10
-11
No files found.
sfu.go
View file @
f5cb2ff3
...
...
@@ -81,10 +81,22 @@ func main() {
group
.
IceFilename
=
filepath
.
Join
(
dataDir
,
"ice-servers.json"
)
go
group
.
ReadPublicGroups
()
webserver
.
Serve
(
httpAddr
,
dataDir
)
serverDone
:=
make
(
chan
struct
{})
go
func
()
{
err
:=
webserver
.
Serve
(
httpAddr
,
dataDir
)
if
err
!=
nil
{
log
.
Printf
(
"Server: %v"
,
err
)
}
close
(
serverDone
)
}()
terminate
:=
make
(
chan
os
.
Signal
,
1
)
signal
.
Notify
(
terminate
,
syscall
.
SIGINT
,
syscall
.
SIGTERM
)
<-
terminate
webserver
.
Shutdown
()
select
{
case
<-
terminate
:
webserver
.
Shutdown
()
case
<-
serverDone
:
os
.
Exit
(
1
)
}
}
webserver/webserver.go
View file @
f5cb2ff3
...
...
@@ -29,7 +29,7 @@ var server *http.Server
var
StaticRoot
string
func
Serve
(
address
string
,
dataDir
string
)
{
func
Serve
(
address
string
,
dataDir
string
)
error
{
http
.
Handle
(
"/"
,
&
fileHandler
{
http
.
Dir
(
StaticRoot
)})
http
.
HandleFunc
(
"/group/"
,
groupHandler
)
http
.
HandleFunc
(
"/recordings"
,
...
...
@@ -61,16 +61,15 @@ func Serve(address string, dataDir string) {
return
true
})
})
go
func
()
{
var
err
error
err
=
server
.
ListenAndServeTLS
(
filepath
.
Join
(
dataDir
,
"cert.pem"
),
filepath
.
Join
(
dataDir
,
"key.pem"
),
)
if
err
!=
nil
&&
err
!=
http
.
ErrServerClosed
{
log
.
Printf
(
"ListenAndServeTLS: %v"
,
err
)
}
}()
err
:=
server
.
ListenAndServeTLS
(
filepath
.
Join
(
dataDir
,
"cert.pem"
),
filepath
.
Join
(
dataDir
,
"key.pem"
),
)
if
err
==
http
.
ErrServerClosed
{
return
nil
}
return
err
}
func
mungeHeader
(
w
http
.
ResponseWriter
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment