Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
configuration
Commits
3706f75b
Commit
3706f75b
authored
Oct 14, 2013
by
John Jarvis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flock in repos-from-orgs to prevent multiple instances from running
parent
2336b8cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
playbooks/roles/gh_mirror/files/repos_from_orgs.py
+12
-4
playbooks/roles/gh_mirror/tasks/main.yml
+2
-2
No files found.
playbooks/roles/gh_mirror/files/repos_from_orgs.py
View file @
3706f75b
...
...
@@ -13,6 +13,16 @@ import logging
from
os.path
import
dirname
,
abspath
,
join
from
argparse
import
ArgumentParser
def
check_running
(
run_type
=
''
):
pid_file
=
'{}-{}.pid'
.
format
(
os
.
path
.
basename
(
__file__
),
run_type
)
fp
=
open
(
pid_file
,
'w'
)
try
:
fcntl
.
lockf
(
fp
,
fcntl
.
LOCK_EX
|
fcntl
.
LOCK_NB
)
except
IOError
:
# another instance is running
sys
.
exit
(
0
)
def
run_cmd
(
cmd
):
logging
.
debug
(
'running: {}
\n
'
.
format
(
cmd
))
...
...
@@ -74,15 +84,13 @@ def update_repos():
run_cmd
(
'cd {} && git update-server-info'
.
format
(
repo_path
))
if
__name__
==
'__main__'
:
logging
.
basicConfig
(
filename
=
'/var/log/repos-from-orgs.log'
,
level
=
logging
.
DEBUG
)
args
=
parse_args
()
if
args
.
refresh
:
check_running
(
'refresh'
)
refresh_cache
()
else
:
check_running
()
if
not
args
.
datadir
:
print
"Please specificy a repository directory"
sys
.
exit
(
1
)
if
not
os
.
path
.
exists
(
'/var/tmp/repos.json'
):
refresh_cache
()
update_repos
()
playbooks/roles/gh_mirror/tasks/main.yml
View file @
3706f75b
...
...
@@ -30,11 +30,11 @@
-
name
:
creating cron job to update repos
cron
:
name
:
"
update
repos
from
github"
job
:
"
/usr/bin/
flock
-n
/tmp/update-repo.lock
-c
'/usr/bin/python
{{
gh_mirror_app_dir
}}/repos_from_orgs.py
-d
{{
gh_mirror_data_dir
}}'
"
job
:
"
/usr/bin/
python
{{
gh_mirror_app_dir
}}/repos_from_orgs.py
-d
{{
gh_mirror_data_dir
}}
"
-
name
:
creating cron to update github repo list
cron
:
name
:
"
refresh
repo
list
from
github"
job
:
"
/usr/bin/
flock
-n
/tmp/update-github-repo.lock
-c
'/usr/bin/python
{{
gh_mirror_app_dir}}/repos_from_orgs.py
-r'
"
job
:
"
/usr/bin/
python
{{
gh_mirror_app_dir}}/repos_from_orgs.py
-r
"
minute
:
0
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