Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit 604425b

Browse files
author
Peter Schmalfeldt
committed
A few more updates
- [X] Adding support for Multicore CPUs - [X] Adding Robot instructions for dev env to `noindex` - [X] Adding `build id` for build process
1 parent 5d691fb commit 604425b

File tree

7 files changed

+42
-11
lines changed

7 files changed

+42
-11
lines changed

.env.example

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
SELECTED_VERSION="23.9"
2-
NEXT_PUBLIC_SITE_URL="https://sfccdocs.com"
1+
BUILD_ID="local"
32
NEXT_PUBLIC_GOOGLE_ANALYTICS="G-G1ER54K5N0"
3+
NEXT_PUBLIC_SITE_URL="https://sfccdocs.com"
44
PORT=3000
5+
SELECTED_VERSION="23.9"

forever/dev.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"uid": "development",
33
"append": true,
44
"watch": true,
5-
"script": "server.cjs",
5+
"script": "multicore.cjs",
66
"sourceDir": "./",
77
"logFile": "web-dev.log",
88
"outFile": "out-dev.log",

forever/loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"uid": "local",
33
"append": true,
44
"watch": true,
5-
"script": "server.cjs",
5+
"script": "multicore.cjs",
66
"sourceDir": "./",
77
"logFile": "web-loc.log",
88
"outFile": "out-loc.log",

forever/prd.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"uid": "production",
33
"append": true,
44
"watch": true,
5-
"script": "server.cjs",
5+
"script": "multicore.cjs",
66
"sourceDir": "./",
77
"logFile": "web-prd.log",
88
"outFile": "out-prd.log",

multicore.cjs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const cluster = require('cluster')
2+
const Debug = require('debug')
3+
const os = require('os')
4+
5+
const debug = Debug('sfcc-docs:multicore')
6+
7+
const numCPUs = os.cpus().length
8+
9+
if (cluster.isMaster) {
10+
cluster.setupMaster({
11+
exec: 'server.cjs',
12+
})
13+
14+
// Fork workers.
15+
for (let i = 0; i < numCPUs; i++) {
16+
cluster.fork()
17+
}
18+
19+
Object.keys(cluster.workers).forEach((id) => {
20+
debug(`Worker id: ${id}/${numCPUs} with pid: ${cluster.workers[id].process.pid}`)
21+
})
22+
23+
cluster.on('exit', (worker) => {
24+
debug(`Worker ${worker.process.pid} died: Respawning...`)
25+
cluster.fork()
26+
})
27+
}

sfcc-docs.code-workspace

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"markdoc",
4646
"mrmidi",
4747
"msapplication",
48+
"multicore",
4849
"noodp",
4950
"noydir",
5051
"packagelist",
@@ -58,6 +59,7 @@
5859
"postbuild",
5960
"preconfigured",
6061
"reindex",
62+
"Respawning",
6163
"rvest",
6264
"schmalfeldt",
6365
"scriptapi",

src/pages/_app.jsx

+7-6
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ export default function App({ Component, pageProps }) {
8181

8282
const baseURL = process.env.NEXT_PUBLIC_SITE_URL || 'https://sfccdocs.com'
8383
const googleAnalytics = process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS || 'G-G1ER54K5N0'
84+
const isProduction = baseURL === 'https://sfccdocs.com'
8485

8586
const metaTitle = pageProps.markdoc?.frontmatter.metaTitle
8687
const metaDescription = pageProps.markdoc?.frontmatter.metaDescription
8788
const metaKeywords = pageProps.markdoc?.frontmatter.metaKeywords
8889
const metaURL = `${baseURL}${router.pathname}`
90+
const metaIndex = isProduction ? 'index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1, noodp, noydir' : 'noindex, nofollow, noodp, noydir'
8991

9092
const tableOfContents = pageProps.markdoc?.content ? collectHeadings(pageProps.markdoc.content) : []
9193

@@ -104,10 +106,9 @@ export default function App({ Component, pageProps }) {
104106
<meta name="keywords" content={metaKeywords} />
105107

106108
{/* Bot Settings */}
107-
<meta name="googlebot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1" />
108-
<meta name="bingbot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1" />
109-
<meta name="robots" content="noodp,noydir" />
110-
<meta name="robots" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1" />
109+
<meta name="googlebot" content={metaIndex} />
110+
<meta name="bingbot" content={metaIndex} />
111+
<meta name="robots" content={metaIndex} />
111112

112113
{/* PWA Settings */}
113114
<meta name="application-name" content="SFCC Docs" />
@@ -132,7 +133,7 @@ export default function App({ Component, pageProps }) {
132133

133134
{/* Twitter Schema */}
134135
<meta name="twitter:card" content="summary_large_image" />
135-
<meta name="twitter:creator" content="@mrmidi" />
136+
<meta name="twitter:creator" content="@sfccdevops" />
136137
<meta name="twitter:description" content={metaDescription} />
137138
<meta name="twitter:image" content={`${baseURL}/assets/website-card.png`} />
138139
<meta name="twitter:title" content={metaTitle} />
@@ -155,7 +156,7 @@ export default function App({ Component, pageProps }) {
155156
<link rel="mask-icon" href="/assets/icons/mask-icon.png" color="#0f162a" />
156157

157158
{/* PWA Manifest */}
158-
<link rel="manifest" href="/manifest.webmanifest" />
159+
<link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials" />
159160
</Head>
160161
<Layout title={metaTitle} tableOfContents={tableOfContents} isMarkdoc={Boolean(pageProps.markdoc)} isEmbedded={isEmbedded}>
161162
<Component {...pageProps} />

0 commit comments

Comments
 (0)