Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
debomatic-webui
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
debomatic-webui-admins
debomatic-webui
Commits
47202de0
Commit
47202de0
authored
Mar 11, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added Broadcaster class and moved relative bradcast functions there
parent
b74ea8c0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
50 deletions
+64
-50
debomatic-webui/index.js
debomatic-webui/index.js
+5
-39
debomatic-webui/lib/broadcaster.js
debomatic-webui/lib/broadcaster.js
+59
-0
debomatic-webui/lib/utils.js
debomatic-webui/lib/utils.js
+0
-11
No files found.
debomatic-webui/index.js
View file @
47202de0
...
@@ -5,17 +5,15 @@
...
@@ -5,17 +5,15 @@
var
express
=
require
(
'
express
'
)
var
express
=
require
(
'
express
'
)
,
routes
=
require
(
'
./routes
'
)
,
routes
=
require
(
'
./routes
'
)
,
fs
=
require
(
'
fs
'
)
,
path
=
require
(
'
path
'
)
,
Tail
=
require
(
'
tail
'
).
Tail
,
config
=
require
(
'
./lib/config.js
'
)
,
config
=
require
(
'
./lib/config.js
'
)
,
utils
=
require
(
'
./lib/utils.js
'
)
,
utils
=
require
(
'
./lib/utils.js
'
)
,
Client
=
require
(
'
./lib/client.js
'
)
,
Client
=
require
(
'
./lib/client.js
'
)
,
Broadcaster
=
require
(
'
./lib/broadcaster.js
'
)
var
app
=
module
.
exports
=
express
.
createServer
();
var
app
=
module
.
exports
=
express
.
createServer
();
var
io
=
require
(
'
socket.io
'
).
listen
(
app
);
var
io
=
require
(
'
socket.io
'
).
listen
(
app
);
// status
// status
es
var
status
=
{}
var
status
=
{}
status
.
packages
=
[]
status
.
packages
=
[]
...
@@ -43,49 +41,17 @@ app.configure('production', function(){
...
@@ -43,49 +41,17 @@ app.configure('production', function(){
app
.
get
(
'
/
'
,
routes
.
index
);
app
.
get
(
'
/
'
,
routes
.
index
);
app
.
get
(
config
.
routes
.
distribution
,
routes
.
distribution
)
app
.
get
(
config
.
routes
.
distribution
,
routes
.
distribution
)
var
broadcast
=
new
Broadcaster
(
io
.
sockets
,
status
)
io
.
sockets
.
on
(
'
connection
'
,
function
(
socket
)
{
io
.
sockets
.
on
(
'
connection
'
,
function
(
socket
)
{
utils
.
send_distributions
(
socket
)
socket
.
emit
(
'
status
'
,
status
)
client
=
new
Client
(
socket
)
client
=
new
Client
(
socket
)
client
.
send_status
(
status
)
});
});
io
.
sockets
.
on
(
'
disconnect
'
,
function
(
socket
){
io
.
sockets
.
on
(
'
disconnect
'
,
function
(
socket
){
});
});
// watcher on new distributions
fs
.
watch
(
config
.
debomatic
.
path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
utils
.
send_distributions
(
io
.
sockets
);
});
// watcher on build_status
status_watcher
=
new
Tail
(
config
.
debomatic
.
jsonfile
)
status_watcher
.
on
(
'
line
'
,
function
(
new_content
)
{
data
=
null
try
{
data
=
JSON
.
parse
(
new_content
)
}
catch
(
error
)
{
return
}
if
(
data
.
status
==
'
building
'
)
{
status
.
packages
.
push
(
data
)
}
else
if
(
data
.
status
==
'
build-successed
'
||
data
.
status
==
'
build-failed
'
)
{
for
(
i
=
0
;
i
<
status
.
packages
.
length
;
i
++
)
{
p
=
status
.
packages
[
i
]
if
(
p
.
package
==
data
.
package
&&
p
.
distribution
==
data
.
distribution
)
{
status
.
packages
.
splice
(
i
,
1
)
break
}
}
}
io
.
sockets
.
emit
(
config
.
events
.
broadcast
.
status_update
,
data
)
})
var
server
=
app
.
listen
(
config
.
port
,
function
(){
var
server
=
app
.
listen
(
config
.
port
,
function
(){
console
.
log
(
"
Express server listening on port %d in %s mode
"
,
app
.
address
().
port
,
app
.
settings
.
env
);
console
.
log
(
"
Express server listening on port %d in %s mode
"
,
app
.
address
().
port
,
app
.
settings
.
env
);
});
});
debomatic-webui/lib/broadcaster.js
0 → 100644
View file @
47202de0
var
config
=
require
(
'
./config.js
'
)
,
fs
=
require
(
'
fs
'
)
,
Tail
=
require
(
'
tail
'
).
Tail
// watcher on build_status
function
__watch_build_status
(
socket
,
status
)
{
status_watcher
=
new
Tail
(
config
.
debomatic
.
jsonfile
)
status_watcher
.
on
(
'
line
'
,
function
(
new_content
)
{
var
data
=
null
try
{
data
=
JSON
.
parse
(
new_content
)
}
catch
(
error
)
{
return
}
if
(
data
.
status
==
'
building
'
)
{
status
.
packages
.
push
(
data
)
}
else
if
(
data
.
status
==
'
build-successed
'
||
data
.
status
==
'
build-failed
'
)
{
for
(
i
=
0
;
i
<
status
.
packages
.
length
;
i
++
)
{
p
=
status
.
packages
[
i
]
if
(
p
.
package
==
data
.
package
&&
p
.
distribution
==
data
.
distribution
)
{
status
.
packages
.
splice
(
i
,
1
)
break
}
}
}
socket
.
emit
(
config
.
events
.
broadcast
.
status_update
,
data
)
})
}
// watcher on new distributions
function
__watch_distributions
(
socket
)
{
fs
.
watch
(
config
.
debomatic
.
path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
utils
.
get_files_list
(
config
.
debomatic
.
path
,
true
,
function
(
distros
)
{
socket
.
emit
(
config
.
events
.
broadcast
.
distributions
,
distros
);
})
})
}
function
Broadcaster
(
sockets
,
status
)
{
var
sockets
=
sockets
__watch_build_status
(
sockets
,
status
)
__watch_distributions
(
sockets
)
return
{
}
}
module
.
exports
=
Broadcaster
debomatic-webui/lib/utils.js
View file @
47202de0
...
@@ -98,12 +98,6 @@ function __generic_handler_watcher(event_name, socket, data, watch_path, callbac
...
@@ -98,12 +98,6 @@ function __generic_handler_watcher(event_name, socket, data, watch_path, callbac
callback
(
event_name
,
socket
,
data
)
callback
(
event_name
,
socket
,
data
)
}
}
function
__send_distributions
(
event_name
,
socket
)
{
__get_files_list
(
config
.
debomatic
.
path
,
true
,
function
(
distros
){
socket
.
emit
(
event_name
,
distros
);
});
}
utils
=
{
utils
=
{
check_data_distribution
:
function
(
data
)
{
check_data_distribution
:
function
(
data
)
{
return
__check_data_distribution
(
data
)
return
__check_data_distribution
(
data
)
...
@@ -132,11 +126,6 @@ utils = {
...
@@ -132,11 +126,6 @@ utils = {
generic_handler_watcher
:
function
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
{
generic_handler_watcher
:
function
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
{
return
__generic_handler_watcher
(
event_name
,
socket
,
data
,
watch_path
,
callback
);
return
__generic_handler_watcher
(
event_name
,
socket
,
data
,
watch_path
,
callback
);
},
},
send_distributions
:
function
(
socket
,
event_name
)
{
if
(
!
event_name
)
event_name
=
config
.
events
.
broadcast
.
distributions
return
__send_distributions
(
event_name
,
socket
);
},
}
}
module
.
exports
=
utils
module
.
exports
=
utils
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