This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the initial Auxiliary2AzureSearch job (#580)
Progress on NuGet/NuGetGallery#6447
- Loading branch information
1 parent
59ec164
commit 8910efe
Showing
16 changed files
with
282 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Net; | ||
using System.Threading.Tasks; | ||
using Autofac; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using NuGet.Services.AzureSearch; | ||
using NuGet.Services.AzureSearch.Auxiliary2AzureSearch; | ||
|
||
namespace NuGet.Jobs | ||
{ | ||
public class Job : JsonConfigurationJob | ||
{ | ||
private const string ConfigurationSectionName = "Auxiliary2AzureSearch"; | ||
|
||
public override async Task Run() | ||
{ | ||
ServicePointManager.DefaultConnectionLimit = 64; | ||
ServicePointManager.MaxServicePointIdleTime = 10000; | ||
|
||
await _serviceProvider | ||
.GetRequiredService<Auxiliary2AzureSearchCommand>() | ||
.ExecuteAsync(); | ||
} | ||
|
||
protected override void ConfigureAutofacServices(ContainerBuilder containerBuilder) | ||
{ | ||
containerBuilder.AddAzureSearch(); | ||
} | ||
|
||
protected override void ConfigureJobServices(IServiceCollection services, IConfigurationRoot configurationRoot) | ||
{ | ||
services.AddAzureSearch(); | ||
|
||
services.Configure<Auxiliary2AzureSearchConfiguration>(configurationRoot.GetSection(ConfigurationSectionName)); | ||
services.Configure<AzureSearchJobConfiguration>(configurationRoot.GetSection(ConfigurationSectionName)); | ||
services.Configure<AzureSearchConfiguration>(configurationRoot.GetSection(ConfigurationSectionName)); | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
src/NuGet.Jobs.Auxiliary2AzureSearch/NuGet.Jobs.Auxiliary2AzureSearch.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>NuGet.Jobs</RootNamespace> | ||
<AssemblyName>NuGet.Jobs.Auxiliary2AzureSearch</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.CSharp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Job.cs" /> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.*.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
<None Include="NuGet.Jobs.Auxiliary2AzureSearch.nuspec" /> | ||
<None Include="Scripts\Functions.ps1" /> | ||
<None Include="Scripts\PostDeploy.ps1" /> | ||
<None Include="Scripts\PreDeploy.ps1" /> | ||
<None Include="Scripts\nssm.exe" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="MicroBuild.Core"> | ||
<Version>0.3.0</Version> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\NuGet.Services.AzureSearch\NuGet.Services.AzureSearch.csproj"> | ||
<Project>{1a53fe3d-8041-4773-942f-d73aef5b82b2}</Project> | ||
<Name>NuGet.Services.AzureSearch</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<PropertyGroup> | ||
<SignPath>..\..\build</SignPath> | ||
<SignPath Condition="'$(BUILD_SOURCESDIRECTORY)' != ''">$(BUILD_SOURCESDIRECTORY)\build</SignPath> | ||
<SignPath Condition="'$(NuGetBuildPath)' != ''">$(NuGetBuildPath)</SignPath> | ||
<SignType Condition="'$(SignType)' == ''">none</SignType> | ||
</PropertyGroup> | ||
<Import Project="$(SignPath)\sign.targets" Condition="Exists('$(SignPath)\sign.targets')" /> | ||
<Import Project="$(SignPath)\sign.microbuild.targets" Condition="Exists('$(SignPath)\sign.microbuild.targets')" /> | ||
<Import Project="$(SignPath)\sign.scripts.targets" Condition="Exists('$(SignPath)\sign.scripts.targets')" /> | ||
<Import Project="..\..\sign.thirdparty.targets" /> | ||
</Project> |
16 changes: 16 additions & 0 deletions
16
src/NuGet.Jobs.Auxiliary2AzureSearch/NuGet.Jobs.Auxiliary2AzureSearch.nuspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0"?> | ||
<package> | ||
<metadata> | ||
<id>Auxiliary2AzureSearch</id> | ||
<version>$version$</version> | ||
<authors>.NET Foundation</authors> | ||
<owners>.NET Foundation</owners> | ||
<description>Auxiliary2AzureSearch</description> | ||
<copyright>Copyright .NET Foundation</copyright> | ||
</metadata> | ||
<files> | ||
<file src="bin\$configuration$\*.*" target="bin" /> | ||
<file src="Scripts\*.ps1" /> | ||
<file src="Scripts\nssm.exe" /> | ||
</files> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace NuGet.Jobs | ||
{ | ||
public class Program | ||
{ | ||
public static int Main(string[] args) | ||
{ | ||
var job = new Job(); | ||
return JobRunner.Run(job, args).GetAwaiter().GetResult(); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/NuGet.Jobs.Auxiliary2AzureSearch/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly: AssemblyTitle("NuGet.Jobs.Auxiliary2AzureSearch")] | ||
[assembly: ComVisible(false)] | ||
[assembly: Guid("7e6903a4-dbe1-444e-a8e3-c1dbb58243e0")] |
30 changes: 30 additions & 0 deletions
30
src/NuGet.Jobs.Auxiliary2AzureSearch/Scripts/Functions.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Function Uninstall-NuGetService() { | ||
Param ([string]$ServiceName) | ||
|
||
if (Get-Service $ServiceName -ErrorAction SilentlyContinue) | ||
{ | ||
Write-Host Removing service $ServiceName... | ||
Stop-Service $ServiceName -Force | ||
sc.exe delete $ServiceName | ||
Write-Host Removed service $ServiceName. | ||
} else { | ||
Write-Host Skipping removal of service $ServiceName - no such service exists. | ||
} | ||
} | ||
|
||
Function Install-NuGetService() { | ||
Param ([string]$ServiceName, [string]$ServiceTitle, [string]$ScriptToRun) | ||
|
||
Write-Host Installing service $ServiceName... | ||
|
||
$installService = "nssm install $ServiceName $ScriptToRun" | ||
cmd /C $installService | ||
|
||
Set-Service -Name $ServiceName -DisplayName "$ServiceTitle - $ServiceName" -Description "Runs $ServiceTitle." -StartupType Automatic | ||
sc.exe failure $ServiceName reset= 30 actions= restart/5000 | ||
|
||
# Run service | ||
net start $ServiceName | ||
|
||
Write-Host Installed service $ServiceName. | ||
} |
18 changes: 18 additions & 0 deletions
18
src/NuGet.Jobs.Auxiliary2AzureSearch/Scripts/PostDeploy.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
. .\Functions.ps1 | ||
|
||
$jobsToInstall = $OctopusParameters["Jobs.ServiceNames"].Split("{,}") | ||
|
||
Write-Host Installing services... | ||
|
||
$currentDirectory = [string](Get-Location) | ||
|
||
$jobsToInstall.Split("{;}") | %{ | ||
$serviceName = $_ | ||
$serviceTitle = $OctopusParameters["Jobs.$serviceName.Title"] | ||
$scriptToRun = $OctopusParameters["Jobs.$serviceName.Script"] | ||
$scriptToRun = "$currentDirectory\$scriptToRun" | ||
|
||
Install-NuGetService -ServiceName $serviceName -ServiceTitle $serviceTitle -ScriptToRun $scriptToRun | ||
} | ||
|
||
Write-Host Installed services. |
11 changes: 11 additions & 0 deletions
11
src/NuGet.Jobs.Auxiliary2AzureSearch/Scripts/PreDeploy.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
. .\Functions.ps1 | ||
|
||
$jobsToInstall = $OctopusParameters["Jobs.ServiceNames"].Split("{,}") | ||
|
||
Write-Host Removing services... | ||
|
||
$jobsToInstall.Split("{;}") | %{ | ||
Uninstall-NuGetService -ServiceName $_ | ||
} | ||
|
||
Write-Host Removed services. |
Binary file not shown.
17 changes: 17 additions & 0 deletions
17
src/NuGet.Services.AzureSearch/Auxiliary2AzureSearch/Auxiliary2AzureSearchCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Threading.Tasks; | ||
|
||
namespace NuGet.Services.AzureSearch.Auxiliary2AzureSearch | ||
{ | ||
public class Auxiliary2AzureSearchCommand | ||
{ | ||
public async Task ExecuteAsync() | ||
{ | ||
// TODO: implement the job | ||
// https://github.com/NuGet/NuGetGallery/issues/6447 | ||
await Task.Yield(); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/NuGet.Services.AzureSearch/Auxiliary2AzureSearch/Auxiliary2AzureSearchConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace NuGet.Services.AzureSearch.Auxiliary2AzureSearch | ||
{ | ||
public class Auxiliary2AzureSearchConfiguration : AzureSearchJobConfiguration | ||
{ | ||
public string AuxiliaryDataStorageConnectionString { get; set; } | ||
public string AuxiliaryDataStorageContainer { get; set; } | ||
public string AuxiliaryDataStorageDownloadsPath { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters