22
33from fabric .api import env , task
44from fabric .state import output
5- from fabric .context_managers import shell_env , cd
5+ from fabric .context_managers import shell_env , cd
66
77#output.stdout = False
88
1515from deployer .tasks .git import clone_repo , deploy_code , add_remote
1616from deployer .tasks .requirements import install_requirements
1717from deployer .tasks .envfile import envconf
18-
18+ from . tasks . supervisor import restart_all
1919
2020
2121@task
@@ -26,19 +26,24 @@ def setup_environment():
2626 with cd (env .app_dir ):
2727 setup_virtualenv (env .python_version , env .app_name , env .app_dir , env .repo_url )
2828
29+
2930@task
3031def deploy (branch = 'master' , migrate = False ):
3132 with shell_env (HOME = '/home/' + env .user , PATH = "/home/" + env .user + "/.pyenv/bin:$PATH" ):
3233 with cd (env .app_dir ):
3334 deploy_code (env .repo_url , env .app_dir , env .user , branch = branch )
3435 install_requirements (env .app_name , env .python_version )
36+ if env .restart_after_deploy :
37+ restart_all ()
38+
3539
3640@task
3741def git_remote_add (remote_url , repo_name ):
3842 with shell_env (HOME = '/home/' + env .user , PATH = "/home/" + env .user + "/.pyenv/bin:$PATH" ):
3943 with cd (env .app_dir ):
4044 add_remote (remote_url , repo_name , env .app_dir )
4145
46+
4247@task
4348def config (action = None , key = None , value = None ):
4449 '''Manage project configuration via .env
@@ -51,5 +56,4 @@ def config(action=None, key=None, value=None):
5156 with shell_env (HOME = '/home/' + env .user , PATH = "/home/" + env .user + "/.pyenv/bin:$PATH" ):
5257 with cd (env .app_dir ):
5358 envconf (action , key , value )
54- for services in env .supervisor_services :
55- supervisor .restart (services )
59+ restart_all ()
0 commit comments