tag:help.appveyor.com,2012-11-13:/discussions/questions/14917-best-practices-on-how-to-erase-everything-in-destination-deployment-folder-and-restart-the-app-after-deploymentAppVeyor: Discussion 2018-10-19T08:18:36Ztag:help.appveyor.com,2012-11-13:Comment/442719222017-12-13T08:13:22Z2017-12-13T08:13:22ZBest practices on how to erase everything in destination deployment folder and restart the app after deployment<div><p>So it actually only took one line of code:</p>
<p>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</p>
<p>2) To clear the folder before deploying to it on a Ubuntu server</p>
<p>before_deploy:<br>
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</p>
<p>systemctl restart myapp<br>
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.</p></div>yzolotarevtag:help.appveyor.com,2012-11-13:Comment/442719222017-12-13T17:45:46Z2017-12-13T17:45:46ZBest practices on how to erase everything in destination deployment folder and restart the app after deployment<div><p>Thank you for update. This -- "after deploy fires straight after deploy and doesn't wait untill upload is finished." -- looks strange. Are you doing <strong>inline</strong> or <strong>environment</strong> deployment? Difference described <a href="https://www.appveyor.com/docs/deployment/#overview">here</a>.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/442719222017-12-18T06:49:04Z2017-12-18T06:49:04ZBest practices on how to erase everything in destination deployment folder and restart the app after deployment<div><p>I am using environment deployement... Should I be using inline in order for this to run synchroniously? Thank you.</p>
<p>version: 1.0.{build}</p>
<p>branches:<br>
only: - master</p>
<p>image: Visual Studio 2017</p>
<p>configuration: Release</p>
<p>before_build:<br>
- cmd: set ASPNETCORE_ENVIRONMENT=Production - cmd: dotnet restore</p>
<p>build_script:<br>
- cmd: dotnet publish</p>
<p>after_build:<br>
- dir BoatInspectorWebApi\bin\Release\netcoreapp2.0</p>
<p>artifacts:<br>
- path: '\BoatInspectorWebApi\bin\Release\netcoreapp2.0\publish' name: BIAPI type: WebDeployPackage</p>
<p>before_deploy:<br>
ssh user@host -t "ls; rm -r -v /var/www/asp/boat/*; ls; exit; bash --login"</p>
<p>deploy:<br>
- provider: Environment name: YZApplications_SSH</p></div>yzolotarev