Example #1
0
def restart(deployment):
    #we need to check whether uwsgi is started in emperor mode or not.
    emperor = deployment.get_config_value('uwsgi/emperor', True)
    vassals_dir = deployment.get_config_value('uwsgi/vassals_dir')
    #then, check if the master instance of uwsgi exists. If not, there's no
    #need to restart, as it will pick up vassal automatically.
        
    if emperor:
        with cd(vassals_dir):
            if not is_running(deployment):
                #start uwsgi, as it will pick up the vassal from vassal's dir.
                start(deployment)
                return
            if exists(deployment.vassal[0]):
                run("kill -HUP `cat %s/uwsgi.pid`" %
                    deployment.get_config_value('uwsgi/workdir')
                    )
            else:
                scp(
                    deployment.get_config_value('uwsgi/launcher'),
                    vassals_dir + "/" + deployment.vassal[0]
                )
    else:
        stop(deployment)
        start(deployment)
Example #2
0
def start(deployment):
    #we need to check whether uwsgi is started in emperor mode or not.
    emperor = deployment.get_config_value('uwsgi/emperor', True)
    uwsgi_dir = deployment.get_config_value('uwsgi/workdir')
    
    vassal = deployment.vassal
    if emperor:
        #in emperor mode, we create the vassal file.
        vassals_dir = deployment.get_config_value('uwsgi/vassals_dir')
        if not exists(vassals_dir):
            run("mkdir -p %s" % vassals_dir)
        with cd(vassals_dir):
            if not exists(vassal[0]):
                if vassal[1]:
                    run("ln -s %s %s" % (vassal[1], vassal[0]))
                else:
                    scp(
                        deployment.get_config_value('uwsgi/launcher'),
                        vassals_dir + "/" + vassal[0]
                    )
        if not is_running(deployment):
        #let's start main uwsgi instance.
            virtualenv(
                deployment.get_config_value('virtualenv/path'),
                "LANG=pl_PL.UTF-8 LC_ALL=pl_PL.UTF-8 uwsgi --master \
 --emperor %(vassals)s --daemonize %(log)s --pidfile %(pid)s --fastrouter %(sock)s \
 --fastrouter-subscription-server 127.0.0.1:3032" % {
                    "log": uwsgi_dir + "/uwsgi.log",
                    "pid": uwsgi_dir + "/uwsgi.pid",
                    "vassals": vassals_dir,
                    "sock": uwsgi_dir + "/uwsgi.sock"
                }
            )


    else:
        #not emperor mode - start uwsgi process.
        virtualenv(
            deployment.get_config_value('virtualenv/path'),
            "LANG=pl_PL.UTF-8 LC_ALL=pl_PL.UTF-8 uwsgi \
 --daemonize %(log)s --pidfile %(pid)s --socket %(sock)s %(def)s" % {
                "log": project_path + "/uwsgi.log",
                "pid": project_path + "/uwsgi.pid",
                "def": vassal[1],
                "sock": project_path + "/uwsgi.sock"
            }
        )
Example #3
0
def main():
    args = Args()

    puts(colored.yellow('Aruments passed in: ') + str(args.all))
    puts(colored.yellow('Flags detected: ') + str(args.flags))
    arg_cmd = args.get(0)
    puts(colored.cyan('Command: ') + str(arg_cmd))

    if arg_cmd == 'start':
        start_ec2()
    elif arg_cmd == 'stop':
        stop_ec2()
    elif arg_cmd == 'ssh':
        ssh_login()
    elif arg_cmd == 'launch':
        ssh_launch()
    elif arg_cmd == 'scp':
        scp()
    elif arg_cmd == 'attach-volume':
        attach_volume()
    elif arg_cmd == 'detach-volume':
        detach_volume()
    elif arg_cmd == 'create-stack':
        arg1 = args.get(1)
        if arg1:
            stack_name = args.get(1)
            stack_exists = validate_stack_exists(stack_name)
        else:
            stack_name = prompt.query("What's the name of your stack?")
            stack_exists = validate_stack_exists(stack_name)

        if (stack_exists):
            puts(colored.red(f'Stack named {stack_name} already exists'))
        else:
            create_stack(stack_name)

    elif arg_cmd == 'update-stack':
        arg1 = args.get(1)
        if arg1:
            stack_name = args.get(1)
            stack_exists = validate_stack_exists(stack_name)
        else:
            stack_name = choose_stack()
            stack_exists = True

        if not stack_exists:
            puts(colored.red(f'Stack named {stack_name} does not exist'))
        else:
            update_stack(stack_name)

    elif arg_cmd == 'check-status':
        list_all_ec2()
    elif arg_cmd == 'create-ecr':
        # Should this be part of the stack?
        create_ecr_registry()
    elif arg_cmd == 'attach-volume':
        attach_volume()
    elif arg_cmd == 'choose-stack':
        choose_stack()
    elif arg_cmd == 'list-keypairs':
        list_keypairs()
    elif arg_cmd == 'upload-keys':
        upload_keys()
    elif arg_cmd == 'delete-stack':
        arg1 = args.get(1)
        if arg1:
            stack_name = args.get(1)
            stack_exists = validate_stack_exists(stack_name)
        else:
            stack_name = choose_stack()
            stack_exists = True

        if stack_exists:
            delete_stack(stack_name)
        else:
            puts(colored.red(f'Stack {stack_name} does not exist'))
Example #4
0
 def __send_payload(self):
     """Fallback method for synchronization."""
     scp(self.payload, "/tmp")
     if self.delete:
         scp(self.delete, "/tmp")