32
32
BUILD_STATE_FINISHED )
33
33
from readthedocs .builds .models import Build , Version
34
34
from readthedocs .builds .signals import build_complete
35
- from readthedocs .core .utils import send_email , run_on_app_servers , broadcast
35
+ from readthedocs .core .utils import send_email , broadcast
36
36
from readthedocs .core .symlink import PublicSymlink , PrivateSymlink
37
37
from readthedocs .cdn .purge import purge
38
38
from readthedocs .doc_builder .loader import get_builder_class
@@ -395,11 +395,10 @@ def build_docs_html(self):
395
395
396
396
# Gracefully attempt to move files via task on web workers.
397
397
try :
398
- move_files .delay (
399
- version_pk = self .version .pk ,
400
- html = True ,
401
- hostname = socket .gethostname (),
402
- )
398
+ broadcast (type = 'app' , task = move_files ,
399
+ args = [self .version .pk , socket .gethostname ()],
400
+ kwargs = dict (html = True )
401
+ )
403
402
except socket .error :
404
403
# TODO do something here
405
404
pass
@@ -555,25 +554,27 @@ def finish_build(version_pk, build_pk, hostname=None, html=False,
555
554
version .save ()
556
555
557
556
if not pdf :
558
- clear_pdf_artifacts ( version )
557
+ broadcast ( type = 'app' , task = clear_pdf_artifacts , args = [ version . pk ] )
559
558
if not epub :
560
- clear_epub_artifacts ( version )
561
-
562
- move_files (
563
- version_pk = version_pk ,
564
- hostname = hostname ,
565
- html = html ,
566
- localmedia = localmedia ,
567
- search = search ,
568
- pdf = pdf ,
569
- epub = epub ,
570
- )
559
+ broadcast ( type = 'app' , task = clear_epub_artifacts , args = [ version . pk ] )
560
+
561
+ # Sync files to the web servers
562
+ broadcast ( type = 'app' , task = move_files , args = [ version_pk , hostname ] ,
563
+ kwargs = dict (
564
+ html = html ,
565
+ localmedia = localmedia ,
566
+ search = search ,
567
+ pdf = pdf ,
568
+ epub = epub ,
569
+ ))
571
570
572
571
# Symlink project on every web
573
572
broadcast (type = 'app' , task = symlink_project , args = [version .project .pk ])
574
573
574
+ # Update metadata
575
+ broadcast (type = 'app' , task = update_static_metadata , args = [version .project .pk ])
576
+
575
577
# Delayed tasks
576
- update_static_metadata .delay (version .project .pk )
577
578
fileify .delay (version .pk , commit = build .commit )
578
579
update_search .delay (version .pk , commit = build .commit )
579
580
@@ -887,7 +888,6 @@ def update_static_metadata(project_pk, path=None):
887
888
fh = open (path , 'w+' )
888
889
json .dump (metadata , fh )
889
890
fh .close ()
890
- Syncer .copy (path , path , host = socket .gethostname (), is_file = True )
891
891
except (AttributeError , IOError ) as e :
892
892
log .debug (LOG_TEMPLATE .format (
893
893
project = project .slug ,
@@ -909,7 +909,7 @@ def remove_dir(path):
909
909
shutil .rmtree (path , ignore_errors = True )
910
910
911
911
912
- @task (queue = 'web' )
912
+ @task ()
913
913
def clear_artifacts (version_pk ):
914
914
"""Remove artifacts from the web servers"""
915
915
version = Version .objects .get (pk = version_pk )
@@ -920,33 +920,19 @@ def clear_artifacts(version_pk):
920
920
921
921
922
922
def clear_pdf_artifacts (version ):
923
- run_on_app_servers ('rm -rf %s'
924
- % version .project .get_production_media_path (
925
- type_ = 'pdf' , version_slug = version .slug ))
923
+ remove_dir (version .project .get_production_media_path (
924
+ type_ = 'pdf' , version_slug = version .slug ))
926
925
927
926
928
927
def clear_epub_artifacts (version ):
929
- run_on_app_servers ('rm -rf %s'
930
- % version .project .get_production_media_path (
931
- type_ = 'epub' , version_slug = version .slug ))
928
+ remove_dir (version .project .get_production_media_path (
929
+ type_ = 'epub' , version_slug = version .slug ))
932
930
933
931
934
932
def clear_htmlzip_artifacts (version ):
935
- run_on_app_servers ('rm -rf %s'
936
- % version .project .get_production_media_path (
937
- type_ = 'htmlzip' , version_slug = version .slug ))
933
+ remove_dir (version .project .get_production_media_path (
934
+ type_ = 'htmlzip' , version_slug = version .slug ))
938
935
939
936
940
937
def clear_html_artifacts (version ):
941
- run_on_app_servers ('rm -rf %s' % version .project .rtd_build_path (version = version .slug ))
942
-
943
-
944
- @task (queue = 'web' )
945
- def remove_path_from_web (path ):
946
- """Remove the given path from the web servers file system."""
947
- # Santity check for spaces in the path since spaces would result in
948
- # deleting unpredictable paths with "rm -rf".
949
- assert ' ' not in path , "No spaces allowed in path"
950
-
951
- # TODO: We need some proper escaping here for the given path.
952
- run_on_app_servers ('rm -rf {path}' .format (path = path ))
938
+ remove_dir (version .project .rtd_build_path (version = version .slug ))
0 commit comments