Best practices on how to erase everything in destination deployment folder and restart the app after deployment

yzolotarev's Avatar


11 Dec, 2017 01:56 PM


so far I have managed to get a simple deployment procedure running via SFTP. I really need to make two more steps:

1) Erase everything inside the folder that I am deploying to before I deploy a fresh build into it or (even better not sure this is possible) see what has changed and upload only the required and erase the non required.
2) Restart the app after deployment is done.

I can see something like this can be achieved with Web Deploy. I'm currently deplyoing to an Ubuntu machine and it will probably require some extra configuration that I don't really want to get into before double checking on a possibility of an existance of another method.

Is there any other, maybe easir way this can be achieved? Thank you.

  1. 1 Posted by yzolotarev on 13 Dec, 2017 08:13 AM

    yzolotarev's Avatar

    So it actually only took one line of code:

    1) First take the SSH public key from the settings page inside the appveyor project and make sure you put it into the authorized_keys inside user_that_you_are_going_to_login_with_from_appveyor/.ssh/authorized_keys

    2) To clear the folder before deploying to it on a Ubuntu server

      ssh user@host -t "rm -r -v /pathtofolder/*;exit; bash --login"
    3) Now about the restart of the app I wanted to use after_deploy however there is a problem with that. After deploy fires straight after deploy and doesn't wait untill upload is finished. I wanted to use it to run

    systemctl restart myapp
    However the problem seemed to solved itself because systemctl restarted my app at the moment when it was substituted with a new one or maybe at the moment when I call it the first time after the files have been reloaded. So far it seems I have a new app running after I run the script.

  2. Support Staff 2 Posted by Ilya Finkelshte... on 13 Dec, 2017 05:45 PM

    Ilya Finkelshteyn's Avatar

    Thank you for update. This -- "after deploy fires straight after deploy and doesn't wait untill upload is finished." -- looks strange. Are you doing inline or environment deployment? Difference described here.

  3. 3 Posted by yzolotarev on 18 Dec, 2017 06:49 AM

    yzolotarev's Avatar

    I am using environment deployement... Should I be using inline in order for this to run synchroniously? Thank you.

    version: 1.0.{build}

      - master
    image: Visual Studio 2017

    configuration: Release

    - cmd: set ASPNETCORE_ENVIRONMENT=Production
    - cmd: dotnet restore

      - cmd: dotnet publish

      - dir BoatInspectorWebApi\bin\Release\netcoreapp2.0

    - path: '\BoatInspectorWebApi\bin\Release\netcoreapp2.0\publish'
      name: BIAPI
      type: WebDeployPackage
      ssh user@host -t "ls; rm -r -v /var/www/asp/boat/*; ls; exit; bash --login"

      - provider: Environment
        name: YZApplications_SSH

  4. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:25 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac