version: '2.0'

st2ci.setup_st2:
    description: Setup a running instance of StackStorm from git repo.
    type: direct
    input:
        - host
        - repo
        - repo_branch
        - repo_dir
        - debug

    output:
        clone_path: <% $.clone_path %>

    task-defaults:
        on-error:
            - teardown: <% not $.debug %>
            - fail: <% $.debug %>

    tasks:
        clone_repo:
            action: st2cd.git_clone
            input:
                hosts: <% $.host %>
                repo: <% $.repo %>
                branch: <% $.repo_branch %>
                target: <% $.repo_dir %>/st2_<% $.repo_branch %>
            publish:
                clone_path: <% $.clone_repo.get($.host).stdout %>
            on-success:
                - install

        install:
            action: st2ci.install_st2
            input:
                hosts: <% $.host %>
                repo: <% $.clone_path %>
            on-success:
                - start_service

        start_service:
            action: core.remote
            input:
                hosts: <% $.host %>
                cmd: <% $.clone_path %>/tools/launchdev.sh startclean -x



        # Declare error handler(s) here
        teardown:
            action: st2ci.teardown_st2
            input:
                host: <% $.host %>
                repo: <% $.clone_path %>
            on-complete:
                - fail

version: '2.0'

st2ci.setup_st2:
    description: Setup a running instance of StackStorm from git repo.
    type: direct
    input:
        - host
        - repo
        - repo_branch
        - repo_dir
        - debug

    output:
        clone_path: <% $.clone_path %>

    task-defaults:
        on-error:
            - teardown: <% not $.debug %>
            - fail: <% $.debug %>

    tasks:
        clone_repo:
            action: st2cd.git_clone
            input:
                hosts: <% $.host %>
                repo: <% $.repo %>
                branch: <% $.repo_branch %>
                target: <% $.repo_dir %>/st2_<% $.repo_branch %>
            publish:
                clone_path: <% $.clone_repo.get($.host).stdout %>
            on-success:
                - install

        install:
            action: st2ci.install_st2
            input:
                hosts: <% $.host %>
                repo: <% $.clone_path %>
            on-success:
                - start_service

        start_service:
            action: core.remote
            input:
                hosts: <% $.host %>
                cmd: <% $.clone_path %>/tools/launchdev.sh startclean -g -x



        # Declare error handler(s) here
        teardown:
            action: st2ci.teardown_st2
            input:
                host: <% $.host %>
                repo: <% $.clone_path %>
            on-complete:
                - fail

Modify st2ci.mistral to use gunicorn for running st2 API
Modify st2ci.mistral to use gunicorn for running st2 API
