@@ -20,8 +20,7 @@ func GetLogs(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
err := json.NewEncoder(w).Encode(response)
|
if err := json.NewEncoder(w).Encode(response); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Errorln(err)
|
log.Errorln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,8 +38,7 @@ func GetWarnings(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
err := json.NewEncoder(w).Encode(response)
|
if err := json.NewEncoder(w).Encode(response); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Errorln(err)
|
log.Errorln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,8 +65,7 @@ func GetServerConfig(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
err := json.NewEncoder(w).Encode(response)
|
if err := json.NewEncoder(w).Encode(response); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Errorln(err)
|
log.Errorln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ func GetChatMessages(w http.ResponseWriter, r *http.Request) {
|
|||||||
case http.MethodGet:
|
case http.MethodGet:
|
||||||
messages := core.GetAllChatMessages()
|
messages := core.GetAllChatMessages()
|
||||||
|
|
||||||
err := json.NewEncoder(w).Encode(messages)
|
if err := json.NewEncoder(w).Encode(messages); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Errorln(err)
|
log.Errorln(err)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -112,9 +112,7 @@ func handleScraperMetadataPage(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/html")
|
w.Header().Set("Content-Type", "text/html")
|
||||||
err = tmpl.Execute(w, metadata)
|
if err := tmpl.Execute(w, metadata); err != nil {
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.Panicln(err)
|
log.Panicln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ func GetStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
status := core.GetStatus()
|
status := core.GetStatus()
|
||||||
response := webStatusResponse{
|
response := webStatusResponse{
|
||||||
Online: status.Online,
|
Online: status.Online,
|
||||||
ViewerCount: status.ViewerCount,
|
ViewerCount: status.ViewerCount,
|
||||||
LastConnectTime: status.LastConnectTime,
|
LastConnectTime: status.LastConnectTime,
|
||||||
LastDisconnectTime: status.LastDisconnectTime,
|
LastDisconnectTime: status.LastDisconnectTime,
|
||||||
VersionNumber: status.VersionNumber,
|
VersionNumber: status.VersionNumber,
|
||||||
StreamTitle: status.StreamTitle,
|
StreamTitle: status.StreamTitle,
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
@@ -30,12 +30,12 @@ func GetStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type webStatusResponse struct {
|
type webStatusResponse struct {
|
||||||
Online bool `json:"online"`
|
Online bool `json:"online"`
|
||||||
ViewerCount int `json:"viewerCount"`
|
ViewerCount int `json:"viewerCount"`
|
||||||
|
|
||||||
LastConnectTime utils.NullTime `json:"lastConnectTime"`
|
LastConnectTime utils.NullTime `json:"lastConnectTime"`
|
||||||
LastDisconnectTime utils.NullTime `json:"lastDisconnectTime"`
|
LastDisconnectTime utils.NullTime `json:"lastDisconnectTime"`
|
||||||
|
|
||||||
VersionNumber string `json:"versionNumber"`
|
VersionNumber string `json:"versionNumber"`
|
||||||
StreamTitle string `json:"streamTitle"`
|
StreamTitle string `json:"streamTitle"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,24 +92,20 @@ func (c *Client) listenWrite() {
|
|||||||
select {
|
select {
|
||||||
// Send a PING keepalive
|
// Send a PING keepalive
|
||||||
case msg := <-c.pingch:
|
case msg := <-c.pingch:
|
||||||
err := websocket.JSON.Send(c.ws, msg)
|
if err := websocket.JSON.Send(c.ws, msg); err != nil {
|
||||||
if err != nil {
|
|
||||||
c.handleClientSocketError(err)
|
c.handleClientSocketError(err)
|
||||||
}
|
}
|
||||||
// send message to the client
|
// send message to the client
|
||||||
case msg := <-c.ch:
|
case msg := <-c.ch:
|
||||||
err := websocket.JSON.Send(c.ws, msg)
|
if err := websocket.JSON.Send(c.ws, msg); err != nil {
|
||||||
if err != nil {
|
|
||||||
c.handleClientSocketError(err)
|
c.handleClientSocketError(err)
|
||||||
}
|
}
|
||||||
case msg := <-c.usernameChangeChannel:
|
case msg := <-c.usernameChangeChannel:
|
||||||
err := websocket.JSON.Send(c.ws, msg)
|
if err := websocket.JSON.Send(c.ws, msg); err != nil {
|
||||||
if err != nil {
|
|
||||||
c.handleClientSocketError(err)
|
c.handleClientSocketError(err)
|
||||||
}
|
}
|
||||||
case msg := <-c.userJoinedChannel:
|
case msg := <-c.userJoinedChannel:
|
||||||
err := websocket.JSON.Send(c.ws, msg)
|
if err := websocket.JSON.Send(c.ws, msg); err != nil {
|
||||||
if err != nil {
|
|
||||||
c.handleClientSocketError(err)
|
c.handleClientSocketError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,8 +144,7 @@ func (c *Client) listenRead() {
|
|||||||
// read data from websocket connection
|
// read data from websocket connection
|
||||||
default:
|
default:
|
||||||
var data []byte
|
var data []byte
|
||||||
err := websocket.Message.Receive(c.ws, &data)
|
if err := websocket.Message.Receive(c.ws, &data); err != nil {
|
||||||
if err != nil {
|
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
c.doneCh <- true
|
c.doneCh <- true
|
||||||
return
|
return
|
||||||
@@ -162,10 +157,9 @@ func (c *Client) listenRead() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var messageTypeCheck map[string]interface{}
|
var messageTypeCheck map[string]interface{}
|
||||||
err = json.Unmarshal(data, &messageTypeCheck)
|
|
||||||
|
|
||||||
// Bad messages should be thrown away
|
// Bad messages should be thrown away
|
||||||
if err != nil {
|
if err := json.Unmarshal(data, &messageTypeCheck); err != nil {
|
||||||
log.Debugln("Badly formatted message received from", c.Username, c.ws.Request().RemoteAddr)
|
log.Debugln("Badly formatted message received from", c.Username, c.ws.Request().RemoteAddr)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -207,8 +201,7 @@ func (c *Client) userJoined(data []byte) {
|
|||||||
|
|
||||||
func (c *Client) userChangedName(data []byte) {
|
func (c *Client) userChangedName(data []byte) {
|
||||||
var msg models.NameChangeEvent
|
var msg models.NameChangeEvent
|
||||||
err := json.Unmarshal(data, &msg)
|
if err := json.Unmarshal(data, &msg); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Errorln(err)
|
log.Errorln(err)
|
||||||
}
|
}
|
||||||
msg.Type = models.UserNameChanged
|
msg.Type = models.UserNameChanged
|
||||||
@@ -219,8 +212,7 @@ func (c *Client) userChangedName(data []byte) {
|
|||||||
|
|
||||||
func (c *Client) chatMessageReceived(data []byte) {
|
func (c *Client) chatMessageReceived(data []byte) {
|
||||||
var msg models.ChatEvent
|
var msg models.ChatEvent
|
||||||
err := json.Unmarshal(data, &msg)
|
if err := json.Unmarshal(data, &msg); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Errorln(err)
|
log.Errorln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ func createTable() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
_, err = stmt.Exec()
|
if _, err := stmt.Exec(); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Warnln(err)
|
log.Warnln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,12 +50,10 @@ func addMessage(message models.ChatEvent) {
|
|||||||
}
|
}
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
|
|
||||||
_, err = stmt.Exec(message.ID, message.Author, message.Body, message.MessageType, 1, message.Timestamp)
|
if _, err := stmt.Exec(message.ID, message.Author, message.Body, message.MessageType, 1, message.Timestamp); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
err = tx.Commit()
|
if err := tx.Commit(); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,13 +130,12 @@ func saveMessageVisibility(messageIDs []string, visible bool) error {
|
|||||||
args[i+1] = id
|
args[i+1] = id
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = stmt.Exec(args...)
|
if _, err := stmt.Exec(args...); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = tx.Commit(); err != nil {
|
if err := tx.Commit(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ func createAccessTokensTable() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
_, err = stmt.Exec()
|
if _, err := stmt.Exec(); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Warnln(err)
|
log.Warnln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,7 +47,7 @@ func InsertToken(token string, name string, scopes []string) error {
|
|||||||
}
|
}
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
|
|
||||||
if _, err = stmt.Exec(token, name, scopesString); err != nil {
|
if _, err := stmt.Exec(token, name, scopesString); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ func TestString(t *testing.T) {
|
|||||||
const testKey = "test string key"
|
const testKey = "test string key"
|
||||||
const testValue = "test string value"
|
const testValue = "test string value"
|
||||||
|
|
||||||
err := _datastore.SetString(testKey, testValue)
|
if err := _datastore.SetString(testKey, testValue); err != nil {
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ func createWebhooksTable() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
_, err = stmt.Exec()
|
if _, err = stmt.Exec(); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Warnln(err)
|
log.Warnln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,8 +125,7 @@ func GetWebhooksForEvent(event models.EventType) []models.Webhook {
|
|||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var url string
|
var url string
|
||||||
|
|
||||||
err = rows.Scan(&url, &event)
|
if err := rows.Scan(&url, &event); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Debugln(err)
|
log.Debugln(err)
|
||||||
log.Error("There is a problem with the database.")
|
log.Error("There is a problem with the database.")
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -32,16 +32,14 @@ func (s *LocalStorage) Setup() error {
|
|||||||
|
|
||||||
// SegmentWritten is called when a single segment of video is written.
|
// SegmentWritten is called when a single segment of video is written.
|
||||||
func (s *LocalStorage) SegmentWritten(localFilePath string) {
|
func (s *LocalStorage) SegmentWritten(localFilePath string) {
|
||||||
_, err := s.Save(localFilePath, 0)
|
if _, err := s.Save(localFilePath, 0); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Warnln(err)
|
log.Warnln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// VariantPlaylistWritten is called when a variant hls playlist is written.
|
// VariantPlaylistWritten is called when a variant hls playlist is written.
|
||||||
func (s *LocalStorage) VariantPlaylistWritten(localFilePath string) {
|
func (s *LocalStorage) VariantPlaylistWritten(localFilePath string) {
|
||||||
_, err := s.Save(localFilePath, 0)
|
if _, err := s.Save(localFilePath, 0); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Errorln(err)
|
log.Errorln(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -49,8 +47,7 @@ func (s *LocalStorage) VariantPlaylistWritten(localFilePath string) {
|
|||||||
|
|
||||||
// MasterPlaylistWritten is called when the master hls playlist is written.
|
// MasterPlaylistWritten is called when the master hls playlist is written.
|
||||||
func (s *LocalStorage) MasterPlaylistWritten(localFilePath string) {
|
func (s *LocalStorage) MasterPlaylistWritten(localFilePath string) {
|
||||||
_, err := s.Save(localFilePath, 0)
|
if _, err := s.Save(localFilePath, 0); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Warnln(err)
|
log.Warnln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,8 +74,7 @@ func (s *S3Storage) SegmentWritten(localFilePath string) {
|
|||||||
utils.StartPerformanceMonitor(performanceMonitorKey)
|
utils.StartPerformanceMonitor(performanceMonitorKey)
|
||||||
|
|
||||||
// Upload the segment
|
// Upload the segment
|
||||||
_, err := s.Save(localFilePath, 0)
|
if _, err := s.Save(localFilePath, 0); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Errorln(err)
|
log.Errorln(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -92,8 +91,7 @@ func (s *S3Storage) SegmentWritten(localFilePath string) {
|
|||||||
// so the segments and the HLS playlist referencing
|
// so the segments and the HLS playlist referencing
|
||||||
// them are in sync.
|
// them are in sync.
|
||||||
playlistPath := filepath.Join(filepath.Dir(localFilePath), "stream.m3u8")
|
playlistPath := filepath.Join(filepath.Dir(localFilePath), "stream.m3u8")
|
||||||
_, err = s.Save(playlistPath, 0)
|
if _, err := s.Save(playlistPath, 0); err != nil {
|
||||||
if err != nil {
|
|
||||||
_queuedPlaylistUpdates[playlistPath] = playlistPath
|
_queuedPlaylistUpdates[playlistPath] = playlistPath
|
||||||
if pErr, ok := err.(*os.PathError); ok {
|
if pErr, ok := err.(*os.PathError); ok {
|
||||||
log.Debugln(pErr.Path, "does not yet exist locally when trying to upload to S3 storage.")
|
log.Debugln(pErr.Path, "does not yet exist locally when trying to upload to S3 storage.")
|
||||||
@@ -108,8 +106,7 @@ func (s *S3Storage) VariantPlaylistWritten(localFilePath string) {
|
|||||||
// to make sure we're not referring to files in a playlist that don't
|
// to make sure we're not referring to files in a playlist that don't
|
||||||
// yet exist. See SegmentWritten.
|
// yet exist. See SegmentWritten.
|
||||||
if _, ok := _queuedPlaylistUpdates[localFilePath]; ok {
|
if _, ok := _queuedPlaylistUpdates[localFilePath]; ok {
|
||||||
_, err := s.Save(localFilePath, 0)
|
if _, err := s.Save(localFilePath, 0); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Errorln(err)
|
log.Errorln(err)
|
||||||
_queuedPlaylistUpdates[localFilePath] = localFilePath
|
_queuedPlaylistUpdates[localFilePath] = localFilePath
|
||||||
}
|
}
|
||||||
@@ -120,8 +117,7 @@ func (s *S3Storage) VariantPlaylistWritten(localFilePath string) {
|
|||||||
// MasterPlaylistWritten is called when the master hls playlist is written.
|
// MasterPlaylistWritten is called when the master hls playlist is written.
|
||||||
func (s *S3Storage) MasterPlaylistWritten(localFilePath string) {
|
func (s *S3Storage) MasterPlaylistWritten(localFilePath string) {
|
||||||
// Rewrite the playlist to use absolute remote S3 URLs
|
// Rewrite the playlist to use absolute remote S3 URLs
|
||||||
err := s.rewriteRemotePlaylist(localFilePath)
|
if err := s.rewriteRemotePlaylist(localFilePath); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Warnln(err)
|
log.Warnln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,8 +191,7 @@ func (s *S3Storage) rewriteRemotePlaylist(filePath string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p := m3u8.NewMasterPlaylist()
|
p := m3u8.NewMasterPlaylist()
|
||||||
err = p.DecodeFrom(bufio.NewReader(f), false)
|
if err := p.DecodeFrom(bufio.NewReader(f), false); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Warnln(err)
|
log.Warnln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,12 +94,10 @@ func SetStreamAsDisconnected() {
|
|||||||
playlistFilePath := fmt.Sprintf(filepath.Join(config.PrivateHLSStoragePath, "%d/stream.m3u8"), index)
|
playlistFilePath := fmt.Sprintf(filepath.Join(config.PrivateHLSStoragePath, "%d/stream.m3u8"), index)
|
||||||
segmentFilePath := fmt.Sprintf(filepath.Join(config.PrivateHLSStoragePath, "%d/%s"), index, offlineFilename)
|
segmentFilePath := fmt.Sprintf(filepath.Join(config.PrivateHLSStoragePath, "%d/%s"), index, offlineFilename)
|
||||||
|
|
||||||
err := utils.Copy(offlineFilePath, segmentFilePath)
|
if err := utils.Copy(offlineFilePath, segmentFilePath); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Warnln(err)
|
log.Warnln(err)
|
||||||
}
|
}
|
||||||
_, err = _storage.Save(segmentFilePath, 0)
|
if _, err := _storage.Save(segmentFilePath, 0); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Warnln(err)
|
log.Warnln(err)
|
||||||
}
|
}
|
||||||
if utils.DoesFileExists(playlistFilePath) {
|
if utils.DoesFileExists(playlistFilePath) {
|
||||||
@@ -119,16 +117,13 @@ func SetStreamAsDisconnected() {
|
|||||||
variantPlaylist.Segments = variantPlaylist.Segments[:len(variantPlaylist.Segments)]
|
variantPlaylist.Segments = variantPlaylist.Segments[:len(variantPlaylist.Segments)]
|
||||||
}
|
}
|
||||||
|
|
||||||
err = variantPlaylist.Append(offlineFilename, 8.0, "")
|
if err := variantPlaylist.Append(offlineFilename, 8.0, ""); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
err = variantPlaylist.SetDiscontinuity()
|
if err := variantPlaylist.SetDiscontinuity(); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
_, err = f.WriteAt(variantPlaylist.Encode().Bytes(), 0)
|
if _, err := f.WriteAt(variantPlaylist.Encode().Bytes(), 0); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Errorln(err)
|
log.Errorln(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -138,8 +133,7 @@ func SetStreamAsDisconnected() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If "offline" content gets changed then change the duration below
|
// If "offline" content gets changed then change the duration below
|
||||||
err = p.Append(offlineFilename, 8.0, "")
|
if err := p.Append(offlineFilename, 8.0, ""); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Errorln(err)
|
log.Errorln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,13 +143,11 @@ func SetStreamAsDisconnected() {
|
|||||||
log.Errorln(err)
|
log.Errorln(err)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
_, err = f.Write(p.Encode().Bytes())
|
if _, err := f.Write(p.Encode().Bytes()); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Errorln(err)
|
log.Errorln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, err = _storage.Save(playlistFilePath, 0)
|
if _, err := _storage.Save(playlistFilePath, 0); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Warnln(err)
|
log.Warnln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,8 +74,7 @@ func (s *FileWriterReceiverService) uploadHandler(w http.ResponseWriter, r *http
|
|||||||
}
|
}
|
||||||
|
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
_, err = f.Write(data)
|
if _, err := f.Write(data); err != nil {
|
||||||
if err != nil {
|
|
||||||
returnError(err, w)
|
returnError(err, w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ func (t *Transcoder) Start() {
|
|||||||
_commandExec = exec.Command("sh", "-c", command)
|
_commandExec = exec.Command("sh", "-c", command)
|
||||||
|
|
||||||
if t.stdin != nil {
|
if t.stdin != nil {
|
||||||
_commandExec.Stdin = t.stdin
|
_commandExec.Stdin = t.stdin
|
||||||
}
|
}
|
||||||
|
|
||||||
stdout, err := _commandExec.StderrPipe()
|
stdout, err := _commandExec.StderrPipe()
|
||||||
@@ -107,8 +107,7 @@ func (t *Transcoder) Start() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = _commandExec.Start()
|
if err := _commandExec.Start(); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Errorln("Transcoder error. See ", logging.GetTranscoderLogFilePath(), " for full output to debug.")
|
log.Errorln("Transcoder error. See ", logging.GetTranscoderLogFilePath(), " for full output to debug.")
|
||||||
log.Panicln(err, command)
|
log.Panicln(err, command)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,31 +94,27 @@ func createVariantDirectories() {
|
|||||||
// Create private hls data dirs
|
// Create private hls data dirs
|
||||||
utils.CleanupDirectory(config.PublicHLSStoragePath)
|
utils.CleanupDirectory(config.PublicHLSStoragePath)
|
||||||
utils.CleanupDirectory(config.PrivateHLSStoragePath)
|
utils.CleanupDirectory(config.PrivateHLSStoragePath)
|
||||||
|
|
||||||
if len(data.GetStreamOutputVariants()) != 0 {
|
if len(data.GetStreamOutputVariants()) != 0 {
|
||||||
for index := range data.GetStreamOutputVariants() {
|
for index := range data.GetStreamOutputVariants() {
|
||||||
err := os.MkdirAll(path.Join(config.PrivateHLSStoragePath, strconv.Itoa(index)), 0777)
|
if err := os.MkdirAll(path.Join(config.PrivateHLSStoragePath, strconv.Itoa(index)), 0777); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
dir := path.Join(config.PublicHLSStoragePath, strconv.Itoa(index))
|
dir := path.Join(config.PublicHLSStoragePath, strconv.Itoa(index))
|
||||||
log.Traceln("Creating", dir)
|
log.Traceln("Creating", dir)
|
||||||
err = os.MkdirAll(dir, 0777)
|
if err := os.MkdirAll(dir, 0777); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dir := path.Join(config.PrivateHLSStoragePath, strconv.Itoa(0))
|
dir := path.Join(config.PrivateHLSStoragePath, strconv.Itoa(0))
|
||||||
log.Traceln("Creating", dir)
|
log.Traceln("Creating", dir)
|
||||||
err := os.MkdirAll(dir, 0777)
|
if err := os.MkdirAll(dir, 0777); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
dir = path.Join(config.PublicHLSStoragePath, strconv.Itoa(0))
|
dir = path.Join(config.PublicHLSStoragePath, strconv.Itoa(0))
|
||||||
log.Traceln("Creating", dir)
|
log.Traceln("Creating", dir)
|
||||||
err = os.MkdirAll(dir, 0777)
|
if err := os.MkdirAll(dir, 0777); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
main.go
3
main.go
@@ -75,8 +75,7 @@ func main() {
|
|||||||
|
|
||||||
go metrics.Start()
|
go metrics.Start()
|
||||||
|
|
||||||
err := data.SetupPersistence(config.DatabaseFilePath)
|
if err := data.SetupPersistence(config.DatabaseFilePath); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Fatalln("failed to open database", err)
|
log.Fatalln("failed to open database", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ func Start() error {
|
|||||||
|
|
||||||
// websocket chat server
|
// websocket chat server
|
||||||
go func() {
|
go func() {
|
||||||
err := chat.Start()
|
if err := chat.Start(); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestCreateAccessToken(t *testing.T) {
|
func TestCreateAccessToken(t *testing.T) {
|
||||||
_, err := GenerateAccessToken()
|
if _, err := GenerateAccessToken(); err != nil {
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ func Restore(backupFile string, databaseFile string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = db.Exec(rawSql)
|
if _, err := db.Exec(rawSql); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -161,8 +161,7 @@ func GetCacheDurationSecondsForPath(filePath string) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IsValidUrl(urlToTest string) bool {
|
func IsValidUrl(urlToTest string) bool {
|
||||||
_, err := url.ParseRequestURI(urlToTest)
|
if _, err := url.ParseRequestURI(urlToTest); err != nil {
|
||||||
if err != nil {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,4 +235,4 @@ func CleanupDirectory(path string) {
|
|||||||
if err := os.MkdirAll(path, 0777); err != nil {
|
if err := os.MkdirAll(path, 0777); err != nil {
|
||||||
log.Fatalln("Unable to create directory. Please check the ownership and permissions", err)
|
log.Fatalln("Unable to create directory. Please check the ownership and permissions", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user