Skip to content

Commit 158e319

Browse files
committed
Change default serve port to 3000 and add ability to override
1 parent dd08e82 commit 158e319

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Options:
2525

2626
Commands:
2727
generate Converts a source markdown folder or file to an output folder
28-
serve Continuously serve a documentation folder at http://localhost:5000.
28+
serve Continuously serve a documentation folder at http://localhost:3000.
2929
File systems changes will be reflected without having to restart the server.
3030
```
3131

docs/source/contribute/locally.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Follow these steps to contribute to Elastic docs.
2929
```
3030

3131
3. **Run the Binary:**
32-
Use the `serve` command to start serving the documentation at http://localhost:5000. The path to the docset.yml file that you want to build can be specified with `-p`:
32+
Use the `serve` command to start serving the documentation at http://localhost:3000. The path to the docset.yml file that you want to build can be specified with `-p`:
3333
```sh
3434
./docs-builder serve -p ./path/to/docs
3535
```
@@ -53,7 +53,7 @@ Follow these steps to contribute to Elastic docs.
5353
```
5454

5555
3. **Run the Binary:**
56-
Use the `serve` command to start serving the documentation at http://localhost:5000. The path to the docset.yml file that you want to build can be specified with `-p`:
56+
Use the `serve` command to start serving the documentation at http://localhost:3000. The path to the docset.yml file that you want to build can be specified with `-p`:
5757
```sh
5858
.\docs-builder serve -p ./path/to/docs
5959
```
@@ -77,7 +77,7 @@ Follow these steps to contribute to Elastic docs.
7777
```
7878

7979
3. **Run the Binary:**
80-
Use the `serve` command to start serving the documentation at http://localhost:5000. The path to the docset.yml file that you want to build can be specified with `-p`:
80+
Use the `serve` command to start serving the documentation at http://localhost:3000. The path to the docset.yml file that you want to build can be specified with `-p`:
8181
```sh
8282
./docs-builder serve -p ./path/to/docs
8383
```
@@ -101,7 +101,7 @@ git clone https://github.com/elastic/docs-content.git
101101
```
102102

103103
2. **Run the Binary:**
104-
Use the `serve` command to start serving the documentation at http://localhost:5000. The path to the `docset.yml` file that you want to build can be specified with `-p`:
104+
Use the `serve` command to start serving the documentation at http://localhost:3000. The path to the `docset.yml` file that you want to build can be specified with `-p`:
105105
```sh
106106
# macOS/Linux
107107
./docs-builder serve -p ./migration-test
@@ -110,7 +110,7 @@ git clone https://github.com/elastic/docs-content.git
110110
.\docs-builder serve -p .\migration-test
111111
```
112112

113-
Now you should be able to view the documentation locally by navigating to http://localhost:5000.
113+
Now you should be able to view the documentation locally by navigating to http://localhost:3000.
114114

115115
## Step 4: Open a PR [#step-four]
116116

src/docs-builder/Cli/Commands.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ namespace Documentation.Builder.Cli;
1616
internal class Commands(ILoggerFactory logger, ICoreService githubActionsService)
1717
{
1818
/// <summary>
19-
/// Continuously serve a documentation folder at http://localhost:5000.
19+
/// Continuously serve a documentation folder at http://localhost:3000.
2020
/// File systems changes will be reflected without having to restart the server.
2121
/// </summary>
2222
/// <param name="path">-p, Path to serve the documentation.
2323
/// Defaults to the`{pwd}/docs` folder
2424
/// </param>
25+
/// <param name="port">Port to serve the documentation.
2526
/// <param name="ctx"></param>
2627
[Command("serve")]
27-
public async Task Serve(string? path = null, Cancel ctx = default)
28+
public async Task Serve(string? path = null, int port = 3000, Cancel ctx = default)
2829
{
29-
var host = new DocumentationWebHost(path, logger, new FileSystem());
30+
var host = new DocumentationWebHost(path, port, logger, new FileSystem());
3031
await host.RunAsync(ctx);
3132
await host.StopAsync(ctx);
32-
3333
}
3434

3535
/// <summary>

src/docs-builder/Http/DocumentationWebHost.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Elastic.Markdown.Diagnostics;
1111
using Elastic.Markdown.IO;
1212
using Microsoft.AspNetCore.Builder;
13+
using Microsoft.AspNetCore.Hosting;
1314
using Microsoft.AspNetCore.Http;
1415
using Microsoft.Extensions.DependencyInjection;
1516
using Microsoft.Extensions.FileProviders;
@@ -28,7 +29,7 @@ public class DocumentationWebHost
2829

2930
private readonly BuildContext _context;
3031

31-
public DocumentationWebHost(string? path, ILoggerFactory logger, IFileSystem fileSystem)
32+
public DocumentationWebHost(string? path, int port, ILoggerFactory logger, IFileSystem fileSystem)
3233
{
3334
var builder = WebApplication.CreateSlimBuilder();
3435

@@ -53,7 +54,7 @@ public DocumentationWebHost(string? path, ILoggerFactory logger, IFileSystem fil
5354
builder.Services.AddHostedService<ReloadGeneratorService>();
5455

5556
//builder.Services.AddSingleton(logger);
56-
57+
builder.WebHost.UseUrls($"http://localhost:{port}");
5758
_webApplication = builder.Build();
5859
SetUpRoutes();
5960
}

0 commit comments

Comments
 (0)