Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab-deps
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
pipelines
tools
gitlab-deps
Commits
ec4523cd
Commit
ec4523cd
authored
4 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Fix the server to use plain text dependencies as input
parent
d4175d13
No related branches found
No related tags found
1 merge request
!1
Modular
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
gitlab_docker_autodep/main.py
+3
-8
3 additions, 8 deletions
gitlab_docker_autodep/main.py
gitlab_docker_autodep/rebuild.py
+0
-3
0 additions, 3 deletions
gitlab_docker_autodep/rebuild.py
gitlab_docker_autodep/server.py
+3
-48
3 additions, 48 deletions
gitlab_docker_autodep/server.py
with
6 additions
and
59 deletions
gitlab_docker_autodep/main.py
+
3
−
8
View file @
ec4523cd
...
...
@@ -141,15 +141,10 @@ def main():
rebuild_deps
(
gl
,
deps
,
project_path
,
branch_name
,
args
.
dry_run
,
args
.
recurse
)
elif
cmd
==
'
server
'
:
deps
=
read_deps
(
sys
.
stdin
)
# TODO
run_app
(
args
.
url
,
gitlab_token
,
args
.
deps
,
args
.
bind_host
,
args
.
bind_port
,
args
.
webhook_auth_token
,
)
run_app
(
gl
,
deps
,
args
.
bind_host
,
args
.
bind_port
,
args
.
webhook_auth_token
)
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
gitlab_docker_autodep/rebuild.py
+
0
−
3
View file @
ec4523cd
...
...
@@ -26,6 +26,3 @@ def rebuild_deps(gl, project_deps, project_path, branch_name, dry_run,
rebuild
(
gl
,
path
,
wait_and_recurse
)
if
wait_and_recurse
:
stack
.
extend
(
project_deps
.
get
(
path
,
[]))
This diff is collapsed.
Click to expand it.
gitlab_docker_autodep/server.py
+
3
−
48
View file @
ec4523cd
import
gitlab
import
json
import
logging
import
os
import
threading
import
time
try
:
import
Queue
except
ImportError
:
...
...
@@ -15,40 +11,6 @@ from flask import Flask, request, make_response, abort
from
.rebuild
import
rebuild
class
_ReloadableJSONFile
(
object
):
check_interval
=
60
def
__init__
(
self
,
path
):
self
.
path
=
path
self
.
lock
=
threading
.
Lock
()
self
.
_load
()
t
=
threading
.
Thread
(
target
=
self
.
_update_thread
,
name
=
'
File reload thread for %s
'
%
path
)
t
.
setDaemon
(
True
)
t
.
start
()
def
get_contents
(
self
):
with
self
.
lock
:
return
self
.
data
def
_load
(
self
):
with
self
.
lock
:
with
open
(
self
.
path
)
as
fd
:
self
.
data
=
json
.
load
(
fd
)
self
.
stamp
=
os
.
stat
(
self
.
path
).
st_mtime
def
_update_thread
(
self
):
while
True
:
time
.
sleep
(
self
.
check_interval
)
try
:
if
os
.
stat
(
self
.
path
).
st_mtime
>
self
.
stamp
:
self
.
_load
()
except
:
pass
queue
=
Queue
.
Queue
()
...
...
@@ -75,11 +37,7 @@ def _process_request(gl, project_deps, data):
path_with_namespace
,
branch
,
pipeline_status
,
action
)
def
worker_thread
(
gitlab_url
,
gitlab_token
,
project_deps
):
gl
=
gitlab
.
Gitlab
(
gitlab_url
,
private_token
=
gitlab_token
)
if
gitlab_token
:
gl
.
auth
()
def
worker_thread
(
gl
,
project_deps
):
while
True
:
data
=
queue
.
get
()
try
:
...
...
@@ -91,21 +49,18 @@ def worker_thread(gitlab_url, gitlab_token, project_deps):
app
=
Flask
(
__name__
)
def
run_app
(
gitlab_url
,
gitlab_token
,
project_deps_path
,
bind_host
,
bind_port
,
def
run_app
(
gl
,
project_deps
,
bind_host
,
bind_port
,
webhook_token
,
num_workers
=
3
):
app
.
config
.
update
({
'
WEBHOOK_AUTH_TOKEN
'
:
webhook_token
,
})
project_deps
=
_ReloadableJSONFile
(
project_deps_path
)
# Start the worker threads that will process the requests in the
# background.
for
i
in
range
(
num_workers
):
wt
=
threading
.
Thread
(
target
=
worker_thread
,
args
=
(
g
itlab_url
,
gitlab_token
,
project_deps
),
args
=
(
g
l
,
project_deps
),
name
=
'
Worker %d
'
%
(
i
+
1
))
wt
.
setDaemon
(
True
)
wt
.
start
()
...
...
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