I'm trying to deploy Nginx as a reverse proxy into my Service Fabric cluster. I would like to put the nginx.conf file in the config directory and the nginx.exe in the code directory.
How do I get the path to the nginx.conf file in the config directory? I tried using a relative path, but it seems that the name of the config directory is changed when it's deployed. For example, in the Service Manifest I've got:
<ExeHost>
<Program>nginx.exe</Program>
<Arguments>-c ../Config/nginx.conf</Arguments>
<WorkingFolder>CodeBase</WorkingFolder>
</ExeHost>
However, when it's deployed the Config directory is renamed to NginxPkg.Config.1.0.0
The package paths are determined at the time of the deployment. In your case you should put the configuration file in the code package itself.
The paths for the various packages should be obtained from the CodePackageActivationContext at runtime. In case of guest executable that is not using the Service Fabric APIs this is not possible. We are considering to provide a way for you to address / access some of the important parts of the CodePackageActivationContext through environment variables.
You can use a batch file and parse information from SF files and then run the program.
For example, the following PowerShell script retrieves the config package's path (assumes there's only one config package):
$package = [xml] (Get-Content "${env:Fabric_Folder_Application}\${env:Fabric_ServicePackageName}.Package.Current.xml");
echo ("${env:Fabric_Folder_Application}" + '\' + "${env:Fabric_ServicePackageName}" + '.' +
$package.ServicePackage.DigestedConfigPackage.ConfigPackage.Name + '.' +
$package.ServicePackage.DigestedConfigPackage.ConfigPackage.Version);
Note that the format of these files is not public and may change in future runtimes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With