Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jobmanager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Video AG Infrastruktur
jobmanager
Commits
8d0b85cc
Commit
8d0b85cc
authored
8 years ago
by
Andreas Valder
Browse files
Options
Downloads
Patches
Plain Diff
working thumbnail generator
parent
5bbbcd46
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+3
-0
3 additions, 0 deletions
README.md
worker.py
+20
-3
20 additions, 3 deletions
worker.py
with
23 additions
and
3 deletions
README.md
0 → 100644
+
3
−
0
View file @
8d0b85cc
Dependencies:
python3
python-psutil
This diff is collapsed.
Click to expand it.
worker.py
+
20
−
3
View file @
8d0b85cc
...
...
@@ -6,6 +6,10 @@ import sched
import
random
import
traceback
import
configparser
import
psutil
import
os
import
json
import
shlex
config
=
configparser
.
ConfigParser
()
config
.
read
(
'
config.ini
'
)
...
...
@@ -36,14 +40,27 @@ threading.Thread(target=run_scheduler, daemon=True).start()
@sched_func
(
5
)
def
ping_website
():
r
=
requests
.
post
(
config
[
'
API
'
][
'
BASE
'
]
+
'
/jobs/api/ping
'
,
params
=
{
'
apikey
'
:
config
[
'
API
'
][
'
KEY
'
]
,
'
host
'
:
config
[
'
MAIN
'
][
'
HOST
'
]
})
r
=
requests
.
post
(
config
[
'
API
'
][
'
BASE
'
]
+
'
/jobs/api/
worker/
'
+
config
[
'
MAIN
'
][
'
HOST
'
]
+
'
/
ping
'
,
params
=
{
'
apikey
'
:
config
[
'
API
'
][
'
KEY
'
]})
if
not
r
.
status_code
==
200
:
print
(
"
Error sending ping:
"
,
r
)
@sched_func
(
10
)
def
get_jobs
():
r
=
requests
.
post
(
config
[
'
API
'
][
'
BASE
'
]
+
'
/jobs/api/schedule
'
,
json
=
{
'
apikey
'
:
config
[
'
API
'
][
'
KEY
'
],
'
host
'
:
config
[
'
MAIN
'
][
'
HOST
'
],
'
jobtypes
'
:
'
thumbnail
'
})
print
(
r
.
text
)
if
psutil
.
cpu_percent
(
interval
=
3
)
<
70
:
r
=
requests
.
post
(
config
[
'
API
'
][
'
BASE
'
]
+
'
/jobs/api/worker/
'
+
config
[
'
MAIN
'
][
'
HOST
'
]
+
'
/schedule
'
,
json
=
{
'
apikey
'
:
config
[
'
API
'
][
'
KEY
'
],
'
jobtypes
'
:
'
thumbnail
'
})
if
r
.
status_code
==
200
:
threading
.
Thread
(
target
=
executejob
,
daemon
=
True
,
kwargs
=
{
'
data
'
:
r
.
json
()}).
start
()
def
executejob
(
data
):
print
(
data
)
param
=
json
.
loads
(
data
[
'
data
'
])
if
(
data
[
'
type
'
]
==
'
thumbnail
'
):
inputfile
=
'
/mnt/sshfs/video-main/
'
+
param
[
'
path
'
]
outputfile
=
'
/tmp/l_
'
+
str
(
param
[
'
lectureid
'
])
+
'
.png
'
r
=
requests
.
post
(
config
[
'
API
'
][
'
BASE
'
]
+
'
/jobs/api/job/
'
+
str
(
data
[
'
id
'
])
+
'
/ping
'
,
params
=
{
'
apikey
'
:
config
[
'
API
'
][
'
KEY
'
],
'
host
'
:
config
[
'
MAIN
'
][
'
HOST
'
],
'
state
'
:
'
running
'
,
'
status
'
:
'
{}
'
})
os
.
system
(
"
ffmpeg -loglevel error -i
'"
+
shlex
.
quote
(
inputfile
)
+
"'
-ss
'
10:00
'
-vf
'
scale=640:360
'
-frames:v 1
'"
+
shlex
.
quote
(
outputfile
)
+
"'"
)
r
=
requests
.
post
(
config
[
'
API
'
][
'
BASE
'
]
+
'
/jobs/api/job/
'
+
str
(
data
[
'
id
'
])
+
'
/finished
'
,
json
=
{
'
apikey
'
:
config
[
'
API
'
][
'
KEY
'
],
'
status
'
:
'
{}
'
})
print
(
r
)
while
True
:
...
...
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