Deploy net core web api to linux

I was able to deploy a net core web api using NGINX template however it does not create service configuration file.

Is there any other “hidden” setting that need to be set to allow the deployment to create the service file?

Thanks

Hi @mhernandez,

Thanks for getting in touch! I’m sorry to see you’re hitting this unexpected issue with your NGINX deployment. There shouldn’t be any hidden setting required to allow the service file to be created. Am I right to assume you’re using the built-in Deploy to NGINX step? If this is easily reproducible, would you be willing to enable debugging variables in your project (OctopusPrintVariables and OctopusPrintEvaluatedVariables, both with a value of True) and create and deploy a new release? The resulting verbose task log should hopefully give us a clearer picture of your process and how and where it’s failing.

I look forward to hearing back!

Best regards,

Kenny

Hi Kenneth,

Attached are the log and the step definition.
I did not see where the service file is being created.

Thanks

ServerTasks-14494.log.txt (88 KB)

Web API - Linux.json (2.07 KB)

Hi @mhernandez,

Just jumping in for Kenny as he’s offline for now.

I took a look at your step template it looks like there is a typo. In one spot you reference $http_upgrade, but another you reference $http_upgrad, can you please take a look and see if this is a typo and if so can you try running it once remediated?

Is this NGINX server already running, or is this a first-time setup?

Are you expecting the service config file to be here? /lib/systemd/system/nginx.service
https://www.nginx.com/resources/wiki/start/topics/examples/systemd/

You could also take a look at this documentation here: Configure Octopus Deploy project - Octopus Deploy

There is a part toward the end that references the service here: Configure Octopus Deploy project - Octopus Deploy

Please let me know how it goes.

Best,
Jeremy

Hi Jeremy,

I corrected the type but has nothing to do with the missing service file.

NGINX is already up and running and the nginx service file is in the right place, what Octopus is not generating is my application service file, that I will expect to be in here /lib/system/conf.d in my case csi.web.api.service

Thanks

Hi @mhernandez,

Thanks for the update.

It looks like this might not be automatic based on this blog from Shane here: How to install and configure NGINX with Octopus Deploy - Octopus Deploy

Can you please give that a look? I will have Kenny reach out to Shane tonight to see if this blog is still how it must be done or if there is another way at this point.

EDIT: This blog might be dated. It looks like this is for doing this without the built-in NGINX steps but I will leave it here in case it’s useful for now while Kenny and I reach out to Shane.

Please let me know what you think.

Best,
Jeremy

I don’t need to deploy NGINX (it has been already installed).

What seems to be Octo deploy is just doing half of the deployment (put the files, create NGINX configuration file), BUT is missing to create the application service file and start the service.

The analogy with IIS will be that it only deploy files and change the web.config, but did not start the application

Thanks

Hi @mhernandez,

Just to confirm, you took a look at this part of our documentation and it doesn’t fulfill what you are after? I am going to ask some colleagues that are logging on in about 4 hours, but this may help.

Please let me know.

Best,
Jeremy

Hi @mhernandez
Just to keep this one moving while Jeremy is offline, your Task log does show your nginx configuration being installed to /etc/nginx/conf.d/ and nginx being reloaded successfully:

 Copying /root/.local/share/Calamari/Temp/49cbe7f9-5ce3-4b3c-819f-c264f0e00c67/conf/* to /etc/nginx/conf.d...
08:07:43   Info     |       Validating nginx configuration
08:07:43   Verbose  |       nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
08:07:43   Verbose  |       nginx: configuration file /etc/nginx/nginx.conf test is successful
08:07:43   Info     |       Reloading nginx configuration

You seem to mention a different destination for your config file though. Is that where the conflict is occurring? If so you can symlink the file to see if that works for you or configure your template to install in your custom folder at /lib/system/conf.d

For your .NET application the link here describes how to setup the systemd service file which starts your application:

The key here is the following:

  • Add the following code as a bash script for the post-deployment phase.

Let me know if this helps or we need to dig a bit further.

Kind Regards,
Paraic

The last link with the bash script was what I needed; now the deployment is working as expected.

Thanks

1 Like

Hi @mhernandez
Glad to see you got it resolved and thanks for letting us know. Feedback is always appreciated.

Have a good weekend.

Kind Regards,
Paraic