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
70646bc3
Commit
70646bc3
authored
Jul 16, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check code style
parent
18c0c552
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
112 additions
and
59 deletions
+112
-59
debomatic-webui/debomatic-webui.coffee
debomatic-webui/debomatic-webui.coffee
+14
-7
debomatic-webui/lib/broadcaster.coffee
debomatic-webui/lib/broadcaster.coffee
+16
-9
debomatic-webui/lib/client.coffee
debomatic-webui/lib/client.coffee
+45
-25
debomatic-webui/lib/parser.coffee
debomatic-webui/lib/parser.coffee
+1
-1
debomatic-webui/lib/tail.coffee
debomatic-webui/lib/tail.coffee
+2
-2
debomatic-webui/lib/utils.coffee
debomatic-webui/lib/utils.coffee
+34
-15
No files found.
debomatic-webui/debomatic-webui.coffee
View file @
70646bc3
...
...
@@ -33,10 +33,11 @@ app.get "/", routes.index
app
.
get
config
.
routes
.
distribution
,
routes
.
distribution
# parefernces page
app
.
get
config
.
routes
.
preferences
,
routes
.
preferences
if
config
.
routes
.
preferences
if
config
.
routes
.
preferences
app
.
get
config
.
routes
.
preferences
,
routes
.
preferences
# commands page
app
.
get
config
.
routes
.
commands
,
routes
.
commands
if
config
.
routes
.
commands
app
.
get
config
.
routes
.
commands
,
routes
.
commands
if
config
.
routes
.
commands
# debomatic static page
if
config
.
routes
.
debomatic
...
...
@@ -50,8 +51,10 @@ if config.routes.debomatic
base
+=
(
if
base
[
base
.
length
-
1
]
isnt
"/"
then
"/"
else
""
)
# append /
match
=
req
.
url
.
replace
(
base
,
""
).
split
(
"/"
)
match
.
pop
()
if
match
[
match
.
length
-
1
]
is
""
# case unstable/unstable
if
match
.
length
>=
2
and
((
match
[
0
]
is
match
[
1
])
or
(
match
[
1
]
is
"build"
and
match
.
length
>
2
))
# case unstable/build/*
if
match
.
length
>=
2
and
((
match
[
0
]
is
match
[
1
])
or
# case unstable/unstable
(
match
[
1
]
is
"build"
and
match
.
length
>
2
))
# case unstable/build/*
res
.
status
(
403
).
send
"<h1>403 Forbidden</h1>"
else
# call next() here to move on to next middleware/router
next
()
...
...
@@ -77,7 +80,8 @@ server.listen config.port, config.host, null, (err) ->
# and set his user id
uid
=
parseInt
(
process
.
env
.
SUDO_UID
)
if
uid
console
.
log
"Please do not run nodejs with sudo. Changing user to %d"
,
uid
console
.
log
"Please do not run nodejs with sudo. "
+
"Changing user to %d"
,
uid
process
.
setgid
uid
process
.
setuid
uid
...
...
@@ -87,11 +91,14 @@ server.listen config.port, config.host, null, (err) ->
io
.
sockets
.
on
"connection"
,
(
socket
)
->
client
=
new
Client
(
socket
)
client
.
start
()
client
.
send_status
status
if
status
.
length
>
0
client
.
send_status
status
if
status
.
length
>
0
client
.
send_status_debomatic
()
return
console
.
log
"Debomatic-webui listening on %s:%d in %s mode"
,
server
.
address
().
address
,
server
.
address
().
port
,
app
.
settings
.
env
console
.
log
"Debomatic-webui listening on %s:%d in %s mode"
,
server
.
address
().
address
,
server
.
address
().
port
,
app
.
settings
.
env
return
server
.
on
"error"
,
(
e
)
->
...
...
debomatic-webui/lib/broadcaster.coffee
View file @
70646bc3
...
...
@@ -2,7 +2,7 @@ __watch_status_check_same_obj = (obj1, obj2) ->
if
obj1
.
status
is
obj2
.
status
if
obj1
.
distribution
is
obj2
.
distribution
if
obj1
.
hasOwnProperty
(
"package"
)
and
obj2
.
hasOwnProperty
(
"package"
)
return
true
if
obj1
.
package
is
obj2
.
package
return
true
if
obj1
.
package
is
obj2
.
package
return
false
return
true
false
...
...
@@ -15,7 +15,9 @@ __watch_status = (socket, status) ->
try
data
=
JSON
.
parse
(
new_content
)
catch
err
utils
.
errors_handler
"Broadcaster:__watch_status:JSON.parse(new_content) - "
,
err
,
socket
utils
.
errors_handler
"Broadcaster:"
+
"__watch_status:JSON.parse(new_content) - "
,
err
,
socket
return
# looking for same status already in statuses lists
...
...
@@ -55,21 +57,26 @@ __watch_distributions = (socket) ->
return
__watch_pidfile
=
(
socket
)
->
fs
.
watchFile
config
.
debomatic
.
pidfile
,
fs
.
watchFile
config
.
debomatic
.
pidfile
,
{
persistent
:
false
interval
:
1007
}
,
(
curr
,
prev
)
->
status_debomatic
=
running
:
curr
.
ino
isnt
0
# if === 0 means pidfile does not exists
# if === 0 means pidfile does not exists
status_debomatic
=
running
:
curr
.
ino
isnt
0
try
socket
.
emit
socket
.
emit
(
config
.
events
.
broadcast
.
status_debomatic
,
status_debomatic
)
socket
.
emit
socket
.
emit
(
config
.
events
.
broadcast
.
status_debomatic
,
status_debomatic
)
return
return
Broadcaster
=
(
sockets
,
status
)
->
__watch_status
sockets
,
status
__watch_distributions
sockets
__watch_pidfile
sockets
{}
__watch_status
(
sockets
,
status
)
__watch_distributions
(
sockets
)
__watch_pidfile
(
sockets
)
"use strict"
config
=
require
(
"./config"
)
fs
=
require
(
"fs"
)
...
...
debomatic-webui/lib/client.coffee
View file @
70646bc3
...
...
@@ -6,22 +6,26 @@ __get_files_list_from_package = (data, callback) ->
data
.
package
.
sources
=
[]
files
.
forEach
(
f
)
->
file
=
{}
file
.
path
=
path
.
join
(
package_path
,
f
).
replace
(
config
.
debomatic
.
path
,
config
.
routes
.
debomatic
)
file
.
path
=
path
.
join
(
package_path
,
f
)
.
replace
(
config
.
debomatic
.
path
,
config
.
routes
.
debomatic
)
file
.
orig_name
=
f
file
.
name
=
f
.
split
(
"_"
)[
0
]
file
.
extension
=
f
.
split
(
"."
).
pop
()
return
if
config
.
debomatic
.
excluded_files
.
indexOf
(
file
.
extension
)
>=
0
if
file
.
extension
is
"deb"
or
file
.
extension
is
"ddeb"
or
file
.
extension
is
"udeb"
data
.
package
.
debs
.
push
file
else
if
f
.
indexOf
(
".tar"
)
>=
0
or
file
.
extension
is
"changes"
or
file
.
extension
is
"dsc"
file
.
name
=
f
.
replace
(
data
.
package
.
name
+
"_"
+
data
.
package
.
version
+
"."
,
""
)
return
if
file
.
extension
in
config
.
debomatic
.
excluded_files
if
file
.
extension
in
[
"deb"
,
"ddeb"
,
"udeb"
]
data
.
package
.
debs
.
push
(
file
)
else
if
file
.
extension
in
[
"changes"
,
"dsc"
]
or
f
.
indexOf
(
'.tar'
)
>
0
file
.
name
=
f
.
replace
(
data
.
package
.
orig_name
+
"."
,
""
)
if
file
.
extension
is
"changes"
file
.
name
=
file
.
extension
else
file
.
name
=
"orig."
+
f
.
split
(
".orig."
).
pop
()
if
f
.
indexOf
(
".tar"
)
>=
0
and
f
.
indexOf
(
".orig."
)
>
0
data
.
package
.
sources
.
push
file
else
if
f
.
indexOf
(
'.orig.tar'
)
>
0
file
.
name
=
"orig."
+
f
.
split
(
".orig."
).
pop
()
data
.
package
.
sources
.
push
(
file
)
else
file
.
name
=
file
.
extension
data
.
package
.
files
.
push
file
data
.
package
.
files
.
push
(
file
)
return
callback
data
...
...
@@ -46,7 +50,9 @@ __read_package_status = (data, cb) ->
try
content
=
JSON
.
parse
(
content
)
catch
parse_err
utils
.
errors_handler
"Client:__read_package_status:parse_err:"
,
parse_err
utils
.
errors_handler
(
"Client:"
+
"__read_package_status:parse_err:"
,
parse_err
)
return
cb
content
return
...
...
@@ -93,26 +99,30 @@ __send_file = (event_name, socket, data, last_lines) ->
return
data
.
file
.
orig_name
=
file_path
.
split
(
"/"
).
pop
()
if
last_lines
>
0
data
.
file
.
content
=
content
.
split
(
"
\n
"
)
.
slice
(
-
last_lines
)
.
join
(
"
\n
"
)
data
.
file
.
content
=
content
.
split
(
"
\n
"
)
[
-
last_lines
..]
.
join
(
"
\n
"
)
else
data
.
file
.
content
=
content
data
.
file
.
path
=
file_path
.
replace
(
config
.
debomatic
.
path
,
config
.
routes
.
debomatic
)
data
.
file
.
path
=
file_path
.
replace
(
config
.
debomatic
.
path
,
config
.
routes
.
debomatic
)
socket
.
emit
event_name
,
data
return
return
__handler_get_file
=
(
socket
,
data
)
->
file_path
=
utils
.
get_file_path
(
data
)
utils
.
watch_path_onsocket
_e
.
file_newcontent
,
socket
,
data
,
file_path
,
(
event_name
,
socket
,
data
)
->
send
=
(
event_name
,
socket
,
data
)
->
data
.
file
.
content
=
null
socket
.
emit
event_name
,
data
return
utils
.
watch_path_onsocket
_e
.
file_newcontent
,
socket
,
data
,
file_path
,
send
if
config
.
web
.
file
.
preview
.
indexOf
(
data
.
file
.
name
)
>=
0
and
not
data
.
file
.
force
__send_file
_e
.
file
,
socket
,
data
,
config
.
web
.
file
.
num_lines
if
data
.
file
.
name
in
config
.
web
.
file
.
preview
and
not
data
.
file
.
force
__send_file
(
_e
.
file
,
socket
,
data
,
config
.
web
.
file
.
num_lines
)
else
__send_file
_e
.
file
,
socket
,
data
__send_file
(
_e
.
file
,
socket
,
data
)
return
Client
=
(
socket
)
->
@
start
=
->
...
...
@@ -121,27 +131,37 @@ Client = (socket) ->
# init events
socket
.
on
_e
.
distribution_packages
,
(
data
)
->
return
unless
utils
.
check_data_distribution
(
data
)
distribution_path
=
path
.
join
(
config
.
debomatic
.
path
,
data
.
distribution
.
name
,
"pool"
)
utils
.
generic_handler_watcher
_e
.
distribution_packages
,
socket
,
data
,
distribution_path
,
__send_distribution_packages
return
unless
utils
.
check_data_distribution
(
data
)
distribution_path
=
path
.
join
(
config
.
debomatic
.
path
,
data
.
distribution
.
name
,
"pool"
)
utils
.
generic_handler_watcher
(
_e
.
distribution_packages
,
socket
,
data
,
distribution_path
,
__send_distribution_packages
)
data
=
null
return
socket
.
on
_e
.
package_files_list
,
(
data
)
->
return
unless
utils
.
check_data_package
(
data
)
return
unless
utils
.
check_data_package
(
data
)
package_path
=
utils
.
get_package_path
(
data
)
utils
.
generic_handler_watcher
_e
.
package_files_list
,
socket
,
data
,
package_path
,
__send_package_files_list
utils
.
generic_handler_watcher
(
_e
.
package_files_list
,
socket
,
data
,
package_path
,
__send_package_files_list
)
data
=
null
return
socket
.
on
_e
.
file
,
(
data
)
->
return
unless
utils
.
check_data_file
(
data
)
return
unless
utils
.
check_data_file
(
data
)
__handler_get_file
socket
,
data
data
=
null
return
socket
.
on
_e
.
package_info
,
(
data
)
->
return
unless
utils
.
check_data_package
(
data
)
return
unless
utils
.
check_data_package
(
data
)
__send_package_info
socket
,
data
data
=
null
return
...
...
@@ -150,7 +170,7 @@ Client = (socket) ->
# on client disconnection close all watchers
socket
.
on
"disconnect"
,
->
socket_watchers
=
socket
.
watchers
return
unless
socket_watchers
return
unless
socket_watchers
for
key
of
socket_watchers
try
socket_watchers
[
key
].
close
()
...
...
debomatic-webui/lib/parser.coffee
View file @
70646bc3
...
...
@@ -2,7 +2,7 @@
Parser
=
->
args
=
process
.
argv
.
slice
(
2
)
help
=
->
console
.
log
"Usage: %s [-c config]
\n
-h
print this help
\n
-c
set user configuration file"
,
process
.
argv
[
1
].
split
(
"/"
).
pop
()
console
.
log
"Usage: %s [-c config]
\n
-h
print this help
\n
-c
set user configuration file"
,
process
.
argv
[
1
].
split
(
"/"
).
pop
()
process
.
exit
0
return
...
...
debomatic-webui/lib/tail.coffee
View file @
70646bc3
...
...
@@ -8,14 +8,14 @@ Tail::watchEvent = (e) ->
if
err
_this
.
emit
"error"
,
err
return
_this
.
pos
=
stats
.
size
if
stats
.
size
<
_this
.
pos
_this
.
pos
=
stats
.
size
if
stats
.
size
<
_this
.
pos
if
stats
.
size
>
_this
.
pos
_this
.
queue
.
push
start
:
_this
.
pos
end
:
stats
.
size
_this
.
pos
=
stats
.
size
_this
.
internalDispatcher
.
emit
"next"
if
_this
.
queue
.
length
is
1
_this
.
internalDispatcher
.
emit
"next"
if
_this
.
queue
.
length
is
1
else
if
e
is
"rename"
@
unwatch
()
...
...
debomatic-webui/lib/utils.coffee
View file @
70646bc3
__errors_handler
=
(
from
,
err
,
socket
)
->
from
=
"NO SOCKET: "
+
from
unless
socket
from
=
"NO SOCKET: "
+
from
unless
socket
console
.
error
from
,
err
.
message
socket
.
emit
config
.
events
.
error
,
err
.
message
if
socket
socket
.
emit
config
.
events
.
error
,
err
.
message
if
socket
return
__check_no_backward
=
(
backward_path
)
->
try
return
backward_path
.
indexOf
(
".."
)
<
0
catch
err
return
true
return
__check_data_distribution
=
(
data
)
->
__check_no_backward
(
data
)
and
__check_no_backward
(
data
.
distribution
)
and
__check_no_backward
(
data
.
distribution
.
name
)
__check_no_backward
(
data
)
and
__check_no_backward
(
data
.
distribution
)
and
__check_no_backward
(
data
.
distribution
.
name
)
__check_data_package
=
(
data
)
->
__check_data_distribution
(
data
)
and
__check_no_backward
(
data
.
package
)
and
__check_no_backward
(
data
.
package
.
name
)
and
__check_no_backward
(
data
.
package
.
version
)
__check_data_distribution
(
data
)
and
__check_no_backward
(
data
.
package
)
and
__check_no_backward
(
data
.
package
.
name
)
and
__check_no_backward
(
data
.
package
.
version
)
__check_data_file
=
(
data
)
->
__check_data_package
(
data
)
and
__check_no_backward
(
data
.
file
)
and
__check_no_backward
(
data
.
file
.
name
)
__check_data_package
(
data
)
and
__check_no_backward
(
data
.
file
)
and
__check_no_backward
(
data
.
file
.
name
)
__get_distribution_pool_path
=
(
data
)
->
path
.
join
config
.
debomatic
.
path
,
data
.
distribution
.
name
,
"pool"
path
.
join
(
config
.
debomatic
.
path
,
data
.
distribution
.
name
,
"pool"
)
__get_package_path
=
(
data
)
->
path
.
join
__get_distribution_pool_path
(
data
),
data
.
package
.
name
+
"_"
+
data
.
package
.
version
path
.
join
(
__get_distribution_pool_path
(
data
),
data
.
package
.
orig_name
)
__get_file_path
=
(
data
)
->
path
.
join
__get_package_path
(
data
),
data
.
package
.
name
+
"_"
+
data
.
package
.
version
+
"."
+
data
.
file
.
name
path
.
join
(
__get_package_path
(
data
),
data
.
package
.
orig_name
+
"."
+
data
.
file
.
name
)
__get_files_list
=
(
dir
,
onlyDirectories
,
callback
)
->
fs
.
readdir
dir
,
(
err
,
files
)
->
result
=
[]
...
...
@@ -32,9 +48,9 @@ __get_files_list = (dir, onlyDirectories, callback) ->
complete_path
=
path
.
join
(
dir
,
f
)
stat
=
fs
.
statSync
(
complete_path
)
if
onlyDirectories
result
.
push
f
if
stat
.
isDirectory
()
result
.
push
f
if
stat
.
isDirectory
()
else
result
.
push
f
if
stat
.
isFile
()
result
.
push
f
if
stat
.
isFile
()
catch
fs_error
__errors_handler
"__get_files_list:forEach"
,
fs_error
return
...
...
@@ -57,7 +73,7 @@ __watch_path_onsocket = (event_name, socket, data, watch_path, updater) ->
watcher
=
fs
.
watch
(
watch_path
,
persistent
:
true
,
(
event
,
fileName
)
->
updater
event_name
,
socket
,
data
if
event
is
"rename"
updater
event_name
,
socket
,
data
if
event
is
"rename"
return
)
else
if
stats
.
isFile
()
...
...
@@ -76,7 +92,10 @@ __watch_path_onsocket = (event_name, socket, data, watch_path, updater) ->
return
catch
err
__errors_handler
"__watch_path_onsocket <- "
+
arguments_
.
callee
.
caller
.
name
,
err
,
socket
__errors_handler
(
"__watch_path_onsocket <- "
+
arguments_
.
callee
.
caller
.
name
,
err
,
socket
)
return
return
__generic_handler_watcher
=
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
->
...
...
@@ -91,18 +110,18 @@ __send_distributions = (socket) ->
data
.
distribution
=
{}
data
.
distribution
.
name
=
dir
pool_path
=
__get_distribution_pool_path
(
data
)
distributions
.
push
dir
if
fs
.
existsSync
(
pool_path
)
distributions
.
push
dir
if
fs
.
existsSync
(
pool_path
)
return
socket
.
emit
config
.
events
.
broadcast
.
distributions
,
distributions
return
return
"use strict"
path
=
require
(
"path"
)
fs
=
require
(
"fs"
)
config
=
require
(
"./config"
)
Tail
=
require
(
"./tail"
)
utils
=
check_data_distribution
:
(
data
)
->
__check_data_distribution
data
...
...
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