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.
Related
I wanted to mock some of my files, so I used Cuckoo framework. I am using Swift Package Manager, so I did every step that is shown in README of framework.
I tried to use this script
# Define output file. Change "${PROJECT_DIR}/${PROJECT_NAME}Tests" to your test's
root source folder, if it's not the default name.
OUTPUT_FILE="${PROJECT_DIR}/${PROJECT_NAME}Tests/GeneratedMocks.swift"
echo "Generated Mocks File = ${OUTPUT_FILE}"
# Define input directory. Change "${PROJECT_DIR}/${PROJECT_NAME}" to your project's root source folder, if it's not the default name.
INPUT_DIR="${PROJECT_DIR}/${PROJECT_NAME}"
echo "Mocks Input Directory = ${INPUT_DIR}"
# Generate mock files, include as many input files as you'd like to create mocks for.
"${PROJECT_DIR}/run" --download generate --testable "${PROJECT_NAME}" \
--output "${OUTPUT_FILE}" \
"${INPUT_DIR}/Common/Repository/LatestNewsRepository/LatestNewsRepositoryImpl.swift" \
# ... and so forth, the last line should never end with a backslash
# After running once, locate `GeneratedMocks.swift` and drag it into your Xcode test target group.
I also downloaded the latest run script and I had to check For install builds only.
When app is launched I am getting this error -
Stale file '.../LibraryTests/GeneratedMocks.swift' is located outside of the allowed root paths.
Things I tried -
Clean Xcode derived data
Clean build folder
Reset Xcode
Reset Packages Cache
and I am still not getting output file. Is there anything else I should try?
I have a TeamCity CI server which pushes the service fabric app in a zip to octopus. This goes well.
My connection from octopus to the azure service fabric cluster is healthy.
I make a release from de zip package in my project
I Deploy the package. Acquire packages goes well
Deploy step goes wrong
It says the following in the logs: Deploying package: E:\Octopus\Packages\Spaces-1\feeds-builtin\xxSF\xxSF.1.0.0.225.zip
I have tried to change the path in Octopus Deploy but I cannot find the place where you can change this. I have read the documentation for octopus deploy but it did not help
Get-Content : Cannot find path ‘C:\Octopus\Work\20190501091314-1918-1033\staging\ApplicationManifest.xml’ because it does not exist.
I do not understand where this path comes from, my guess is that this path is the place where the packages are. My ApplicationManifest.xml is in the zip package. Does anyone know what I have to do here?
Checked the RAW logs
I saw this:
Info | Deploying package: E:\Octopus\Packages\Spaces-1\feeds-builtin\xx\xx.1.0.0.225.zip
Verbose | Extracting package to: C:\Octopus\Work\20190501091314-1918-1033\staging
Verbose | Extracted 90 files
Verbose | Performing variable substitution on ‘C:\Octopus\Work\20190501091314-1918-1033\staging\packages.config’
Verbose | Performing variable substitution on ‘C:\Octopus\Work\20190501091314-1918-1033\staging\ApplicationPackageRoot\ApplicationManifest.xml’
Verbose | Performing variable substitution on ‘C:\Octopus\Work\20190501091314-1918-1033\staging\ApplicationParameters\Cloud.xml’
Verbose | Performing variable substitution on ‘C:\Octopus\Work\20190501091314-1918-1033\staging\ApplicationParameters\Local.1Node.xml’
Verbose | Performing variable substitution on ‘C:\Octopus\Work\20190501091314-1918-1033\staging\ApplicationParameters\Local.5Node.xml’
Verbose | Performing variable substitution on ‘C:\Octopus\Work\20190501091314-1918-1033\staging\PackageRoot\ServiceManifest.xml’
Verbose | Performing variable substitution on ‘C:\Octopus\Work\20190501091314-1918-1033\staging\PackageRoot\Config\Settings.xml’
Verbose | Performing variable substitution on ‘C:\Octopus\Work\20190501091314-1918-1033\staging\PublishProfiles\Cloud.xml’
Verbose | Performing variable substitution on ‘C:\Octopus\Work\20190501091314-1918-1033\staging\PublishProfiles\Local.1Node.xml’
Verbose | Performing variable substitution on ‘C:\Octopus\Work\20190501091314-1918-1033\staging\PublishProfiles\Local.5Node.xml’
Get-Content : Cannot find path ‘C:\Octopus\Work\20190501091314-1918-1033\staging\ApplicationManifest.xml’ because it
Error | does not exist.
It looks like it cannot find the subfolder staging\ApplicationPackageRoot, ApplicationManifest.xml is in this subfolder.
I fixed the problem. This is the solution:
Make sure your package that you upload from whatever CI Server you use has the following directories/file and structure:
ApplicationParameters(Folder)
PublishProfiles(Folder)
YourServiceFabric(Folder with your service fabric application) This has the same name as ServiceManifestName that is mentioned in the ApplicationManifest.xml. This name is specific so make sure that you have the right name. You will have to build the sfproj in order to get the .dll put in this folder.
ApplicationManifest.xml (File)
This is all that Octopus Deploy need to deploy your service fabric application.
My approach was as following: I packaged the Service Fabric Application in Visual Studio and I saw that there where a bunch of specific files that where packed as stated above. I then manually uploaded this package to the octopus deploy server and created a release/deploy. This went well so I gathered the same files from the CI server and pushed this to Octopus Deploy and it worked.
# test.ps1
function foo {
echo "bar"
}
I have a file named test.ps1 which contains some frequently called functions. And I want it to be shared between my jenkins master and slave nodes.
I've tried creating 2 copies of test.ps1 and put them in master and slave nodes. But this is not convenient. Because I'll have to maintain 2 test.ps1s
Another way I've tried is putting 1 test.ps1 at master node and copying test.ps1 from master to slave with Publish Over SSH Plugin whenever I need to use test.ps1 at slave node. This is not convenient, either.
How can I share test.ps1 between master and slave nodes?
I found that Config File Provider Plugin solves my problem:
First, create a custom file using this plugin:
Write the name and content of this shared file. Then save it.
Inside your project, check Provide Configuration files
Jenkins will create test.ps1 inside Target folder (In my case, I set it to the workspace of the project) whenever you build the project. Note that this folder must exist before building the project.
Variable represents an environment variable with which you can refer to the file test.ps1.
Inside your build step, you can import the file using . $env:util. Then you will be able to call the function foo.
The above can be done no matter whether you are at master or slave node.
I've got a .NET WebAPI solution, and a UI built in Angular2 RC4 (angular-cli webpack version). I'm confused about how to deploy these to different environments, especially configuration parameters - there seems to be a mismatch between the .NET way and the UI way of doing things, which I don't quite get.
Here's how I've got it currently in TeamCity. The WebAPI solution is built once only, and is configured at deploy time. The various configuration parameters the project needs (such as connection strings, endpoints etc.) are stored in web.config. When I deploy to my test environment using MSDeploy, I pass in setParam arguments to the MSDeploy command line which replaces the connection strings and endpoints in the web.config with those values. When I deploy to production, I use the same build but pass in different arguments to the setParam in the command line.
This approach makes sense to me because I know that the exact same build is going from one environment to the next, the only difference being the parameters I specifically told it to set for each environment. Super.
With Angular2 and webpack it looks like a different approach is needed. When I build my project (with ng build -prod) it minimizes and bundles my HTML and Javascript files into 3 or 4 files, along with gzipped versions of those files. This is great for reducing file size and increasing speed of my website, but there is no way to "inject" configuration parameters into these gzip files like there is with MSDeploy's setParam. Everywhere I've seen that mentions webpack is showing webpack.dev.config.js and webpack.prod.config.js. But doesn't that mean we need to build a different bundle for each environment? And actually with Angular2 the webpack bit is considered "a black box" and it's not possible to supply your own webpack.config file anyway.
The only workaround I can think of is to use TeamCity's "File Content Replacer" on the "main.1234abcd6946c6a08519.bundle.js" to replace my configuration parameters with the values for that environment, then gzip that file - overwriting the one created by webpack.
But this is horrible, so I'm looking for any better suggestions?
I don't have any experience with webpack or if this is better than your workaround but you can use the TextFile kind of setParam entry to alter any file in your project using Regex find/replace at deploy time.
https://technet.microsoft.com/en-us/library/dd569084(v=ws.10).aspx
I went with creating a separate package for each environment. I added a build step that replaces my API URL on localhost in src\app\environment.ts, with the appropriate URL for that environment, then it runs npm build -prod and then MSDeploy to create the package. I do this for all environments I want to target.
Here's the script:
REM =====CREATE TEST PACKAGE==================================================
REM backup the environment file
ren src\app\environment.ts environment.ts.bak
copy /Y src\app\environment.ts.bak src\app\environment.ts
REM replace localhost in environment file with the TEST environment URL
"%env.FART%" src\app\environment.ts http://localhost:12345 %TEST.api.url%
REM build using this environment
call npm run build-prod
REM restore backup environment file
del /Q src\app\environment.ts
ren src\app\environment.ts.bak environment.ts
REM create TEST package
"%env.MSDEPLOY%" ^
-verb:sync ^
-source:contentPath="%teamcity.build.workingDir%\dist" ^
-dest:package="%teamcity.build.checkoutDir%\Package_TEST.zip"
REM =====CREATE PROD PACKAGE==================================================
REM backup the environment file
ren src\app\environment.ts environment.ts.bak
copy /Y src\app\environment.ts.bak src\app\environment.ts
REM replace localhost in environment file with the PROD environment URL
"%env.FART%" src\app\environment.ts http://localhost:12345 %PROD.api.url%
REM build using this environment
call npm run build-prod
REM restore backup environment file
del /Q src\app\environment.ts
ren src\app\environment.ts.bak environment.ts
REM create PROD package
"%env.MSDEPLOY%" ^
-verb:sync ^
-source:contentPath="%teamcity.build.workingDir%\dist" ^
-dest:package="%teamcity.build.checkoutDir%\Package_PROD.zip"
By the way, %env.FART% is the location of fart.exe which is a great find/replace tool that I use to replace one string in a file with another.
I'm using Sphinx on a Linux production server as well as a Windows dev machine running WampServer.
The index configurations in sphinx.conf each require a path setting for the output file name. Because the filesystems on the production server and dev machine are different, I have to have two lines and then comment one out depending on which server I'm using.
#path = /path/to/folder/name #LIVE
path = C:\wamp\www\site\path\to\folder\name #LOCALHOST
Since I have lots of indexes, it gets really old having to constantly comment and uncomment dozens of lines every time I need to update the file.
Using relative paths would be the ideal solution, but when I tried that I received the following error when running the indexer:
FATAL: failed to open ../folder/name.tmp.spl: Invalid argument, will not index. Try --rotate option.
Is it possible to use relative paths in sphinx.conf?
You can use relative paths, but its kind of tricky because you the various utilities will have different working directories.
eg On windows the searchd service, will start IIRC with a working directory of $WINDIR$\System32
on linux, via crontab, I think it has working directory left over from previously, so would have to change the folder in the actual command line
... ie its not relative to the config file, its relative to the current working directory.
Personally I use a version control system (SVN actually) to manage it. The version from Dev, is always the one commited to the repository, the 'working copy' on the LIVE server, has had the paths edited to the right location. So when 'update' to the latest file, only changes are merged leaving the local filepaths in tact.
Other people use a dynamic config file. The config file can be a script (php/python/perl etc) - but this only works on linux so wont help you.
Or can just have a 'publish' script. Basically, you edit a 'master' config file, and one that can be freely copied to all servers. Then a 'publish' script, that writes the apprirate local path. It could do it with some pretty simple search replace.
<?php
if (trim(`hostname`) == 'live') {
$path = '/path/to/folder/';
} else {
$path = 'C:\wamp\www\site\path\to\folder\`;
}
$contents = file_get_contents('sphinx.conf.master');
$contents = str_replace('$path',$path,$contents);
file_put_contents('sphinx.conf',$contents);
Then have path = $path\name in the master config file, which will get replaced to the proper path, when run the script on the local machine