1

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 not required.
  2. Restart the app after deployment is done.

What could be the best solution for this with Appveyor? So far I see the easiest way is to possibly include a power shell script that will connect via ssh and clear out the folder, not sure how that would work with restarting the app though. Would be really great to hear some more experienced users about this solution.

  • There are number of approaches to this problem. To find more suitable one, please clarify the following: 1. What king of application is it? ASP.NET, ASP.NET Core or some other framework? 2. Do you have control over server or it is some kind of hosting? 3. What was rationale behind using SFTP and not other deployment method? – Ilya Finkelsheyn Dec 11 '17 at 18:08
  • ASP.NET Core, its my own server so full control, sftp seemed like the easiest way to me possibly because I don't know much about other ways that exist. The way I see it now is I only have 1 step left which is write a simple ps script that will connect before deploy clear out the directory and I'm done. However overall I get a feeling there could be a more appropriate approach. Thank you. – Yuri Zolotarev Dec 11 '17 at 18:13
  • Also, I'm pretty sure I won't be able to restart the app via ps so this is a big issue which actually fails the whole process right at the end unfortunatly where I have one little step to go. – Yuri Zolotarev Dec 11 '17 at 18:14
  • So probably best to go some other way straight from the beginning. Since I'm only starting my way in CI would really appreciate some advice on what would be the most appropriate path. Thank you. – Yuri Zolotarev Dec 11 '17 at 18:27
  • So overall its a ASP.NET Core WebApi App that I want to deploy to a Ubuntu 16.04 which I totally control. The server systemctl is set up to fire up the apps specific dll so all I have to do there is to make correction inside the directory or totally erase everything and put new files back inside and possible restart the app as well. – Yuri Zolotarev Dec 11 '17 at 18:30
1

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

before_deploy:    
  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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.