-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure-windows-service.html
More file actions
422 lines (401 loc) · 24.3 KB
/
configure-windows-service.html
File metadata and controls
422 lines (401 loc) · 24.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Run PostgreSQL as a Windows Service — Configure, Start, and Recover</title>
<meta name="description" content="Configure PostgreSQL to run as a Windows service: startup type, service account, recovery options, logs, and firewall notes for Windows 10/11." />
<link rel="canonical" href="https://postgre-sql.github.io/configure-windows-service.html" />
<meta name="last-modified" content="2026-05-01T13:06:51Z" />
<meta name="robots" content="index,follow" />
<meta name="theme-color" content="#336791" />
<!-- Open Graph -->
<meta property="og:type" content="article" />
<meta property="og:title" content="Run PostgreSQL as a Windows Service — Configure, Start, and Recover" />
<meta property="og:description" content="Set up the PostgreSQL Windows service: startup, account, recovery, logs, and firewall basics." />
<meta property="og:url" content="https://postgre-sql.github.io/configure-windows-service.html" />
<meta property="og:site_name" content="PostgreSQL for Windows" />
<meta property="og:image" content="https://postgre-sql.github.io/og-image.png" />
<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Run PostgreSQL as a Windows Service" />
<meta name="twitter:description" content="Configure startup type, account, recovery, logs, and firewall on Windows." />
<meta name="twitter:image" content="https://postgre-sql.github.io/og-image.png" />
<!-- Icons -->
<link rel="icon" href="https://postgre-sql.github.io/favicon.svg" type="image/svg+xml" />
<link rel="alternate icon" href="https://postgre-sql.github.io/favicon.ico" />
<link rel="apple-touch-icon" href="https://postgre-sql.github.io/apple-touch-icon.png" />
<style>
:root{
--bg:#F8FAFC; --panel:#FFFFFF; --text:#0F172A; --muted:#334155; --primary:#336791; --primary-600:#2b5a75; --primary-700:#244a60; --accent:#3E7BB6; --success:#2F855A; --warning:#B7791F; --border:#E2E8F0; --focus:#F59E0B; --shadow:0 2px 10px rgba(15,23,42,.08);
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{margin:0; color:var(--text); background:var(--bg); font:16px/1.55 system-ui,-apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji"}
a{color:var(--primary)}
a:focus, button:focus{outline:3px solid var(--focus); outline-offset:2px}
header{position:sticky; top:0; z-index:50; background:rgba(255,255,255,.9); backdrop-filter:saturate(180%) blur(8px); border-bottom:1px solid var(--border)}
.wrap{max-width:1100px; margin:0 auto; padding:0 16px}
.topbar{display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 0}
.brand{display:flex; align-items:center; gap:10px; color:var(--primary-700); text-decoration:none; font-weight:700}
.brand svg{width:28px;height:28px}
nav ul{list-style:none; margin:0; padding:0; display:flex; gap:14px; flex-wrap:wrap}
nav a{display:inline-flex; align-items:center; gap:6px; text-decoration:none; color:var(--muted); padding:8px 10px; border-radius:8px}
nav a:hover{background:#eef2f7; color:var(--primary-700)}
.breadcrumbs{font-size:14px; color:var(--muted); padding:10px 0}
.breadcrumbs a{text-decoration:none; color:inherit}
.hero{background:linear-gradient(180deg, #fff 0%, #f3f7fb 100%); border-bottom:1px solid var(--border)}
.hero .inner{display:grid; grid-template-columns:1.1fr .9fr; gap:24px; padding:34px 0}
.hero h1{font-size:clamp(26px,3.3vw,38px); line-height:1.15; margin:8px 0 10px}
.hero p.sub{color:var(--muted); margin:0 0 18px}
.btn{appearance:none; border:0; border-radius:10px; padding:12px 16px; display:inline-flex; align-items:center; gap:10px; cursor:pointer; font-weight:700; text-decoration:none}
.btn-primary{background:var(--primary); color:#fff}
.btn-primary:hover{background:var(--primary-600)}
.btn-ghost{background:transparent; color:var(--primary-700); border:2px solid var(--primary-600)}
.btn-ghost:hover{background:#e8f0f9}
.cta-row{display:flex; gap:12px; flex-wrap:wrap}
.note{display:flex; align-items:center; gap:8px; color:var(--muted); font-size:14px; margin-top:10px}
.section{padding:30px 0}
.section h2{margin:0 0 14px; font-size:22px}
.card-grid{display:grid; grid-template-columns:repeat(3,1fr); gap:16px}
.card{background:var(--panel); border:1px solid var(--border); border-radius:14px; padding:16px; box-shadow:var(--shadow)}
.card h3{margin:0 0 8px; font-size:18px}
.card p{margin:0; color:var(--muted)}
.list{margin:10px 0 0; padding-left:18px}
footer{margin-top:24px; border-top:1px solid var(--border); background:#fff}
.footer-inner{display:grid; grid-template-columns:1fr 1fr; gap:16px; padding:18px 0}
.muted{color:var(--muted)}
.disclaimer{background:#fff; border:1px dashed var(--border); padding:14px; border-radius:12px; color:var(--muted)}
.mobile-cta{position:fixed; bottom:12px; left:12px; right:12px; display:none; z-index:30}
.mobile-cta .inner{background:#10263a; border-radius:14px; padding:10px; display:flex; justify-content:space-between; align-items:center; gap:10px; color:#e6f1fa; box-shadow:0 8px 22px rgba(0,0,0,.25)}
.mobile-cta .inner .btn{padding:10px 14px}
/* Cookie banner */
.cookie-banner{position:fixed; z-index:60; inset:auto 12px 12px 12px; background:#fff; border:1px solid var(--border); border-radius:14px; box-shadow:var(--shadow); display:none}
.cookie-content{padding:14px; display:grid; grid-template-columns:1fr auto; gap:12px; align-items:start}
.cookie-actions{display:flex; gap:8px; flex-wrap:wrap}
.cookie-banner .btn{padding:10px 12px}
/* Responsive */
@media (max-width: 900px){
.hero .inner{grid-template-columns:1fr}
.card-grid{grid-template-columns:1fr 1fr}
.footer-inner{grid-template-columns:1fr}
}
@media (max-width: 640px){
.card-grid{grid-template-columns:1fr}
.mobile-cta{display:block}
}
</style>
<!-- SVG Sprite -->
<svg xmlns="http://www.w3.org/2000/svg" style="position:absolute;width:0;height:0;overflow:hidden" aria-hidden="true">
<symbol id="icon-download" viewBox="0 0 24 24" fill="currentColor">
<path d="M12 3a1 1 0 011 1v8.586l2.293-2.293a1 1 0 111.414 1.414l-4.001 4a1 1 0 01-1.412 0l-4.001-4a1 1 0 011.414-1.414L11 12.586V4a1 1 0 011-1z"/>
<path d="M4 15a1 1 0 011-1h2a1 1 0 010 2H6v3h12v-3h-1a1 1 0 110-2h2a1 1 0 011 1v4a2 2 0 01-2 2H6a2 2 0 01-2-2v-4z"/>
</symbol>
<symbol id="icon-external" viewBox="0 0 24 24" fill="currentColor"><path d="M14 3a1 1 0 000 2h3.586l-8.293 8.293a1 1 0 001.414 1.414L19 6.414V10a1 1 0 002 0V4a1 1 0 00-1-1h-6z"/><path d="M5 6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5a1 1 0 10-2 0v5H5V8h5a1 1 0 100-2H5z"/></symbol>
<symbol id="icon-check" viewBox="0 0 24 24" fill="currentColor"><path d="M20.285 6.708a1 1 0 010 1.414l-9.192 9.192a1 1 0 01-1.414 0L3.715 11.55a1 1 0 111.414-1.414l5.1 5.1 8.485-8.485a1 1 0 011.571-.042z"/></symbol>
<symbol id="icon-info" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2a10 10 0 100 20 10 10 0 000-20zm0 6a1.25 1.25 0 110-2.5A1.25 1.25 0 0112 8zm1 9h-2v-6h2v6z"/></symbol>
<symbol id="icon-warning" viewBox="0 0 24 24" fill="currentColor"><path d="M12.882 2.773l9.02 15.625A2 2 0 0120.236 22H3.764a2 2 0 01-1.666-3.602l9.02-15.625a2 2 0 013.764 0zM11 9v5h2V9h-2zm1 8a1.25 1.25 0 100-2.5A1.25 1.25 0 0012 17z"/></symbol>
<symbol id="icon-close" viewBox="0 0 24 24" fill="currentColor"><path d="M6.225 4.811a1 1 0 011.414 0L12 9.172l4.361-4.361a1 1 0 111.414 1.414L13.414 10.586l4.361 4.361a1 1 0 01-1.414 1.414L12 12l-4.361 4.361a1 1 0 01-1.414-1.414l4.361-4.361-4.361-4.361a1 1 0 010-1.414z"/></symbol>
</svg>
<!-- GA4 base tag -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-MHLW57MR8Q"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
gtag('consent','default', { 'analytics_storage':'denied', 'ad_storage':'denied' });
gtag('js', new Date());
gtag('config', 'G-MHLW57MR8Q', { anonymize_ip: true });
</script>
<!-- Schema.org JSON-LD -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "BreadcrumbList",
"itemListElement": [
{"@type": "ListItem", "position": 1, "name": "Home", "item": "https://postgre-sql.github.io/"},
{"@type": "ListItem", "position": 2, "name": "Configure Windows Service", "item": "https://postgre-sql.github.io/configure-windows-service.html"}
]
},
{
"@type": "SoftwareApplication",
"name": "PostgreSQL for Windows",
"operatingSystem": "Windows 11, Windows 10 (64-bit)",
"applicationCategory": "DatabaseApplication",
"softwareVersion": "18.3-3",
"downloadUrl": "https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe",
"offers": {"@type": "Offer", "price": "0", "priceCurrency": "USD", "category": "free"},
"publisher": {"@type": "Organization", "name": "Unofficial PostgreSQL for Windows Guide", "url": "https://postgre-sql.github.io/"}
},
{
"@type":"HowTo",
"name":"Configure PostgreSQL as a Windows Service",
"totalTime":"PT6M",
"step": [
{"@type":"HowToStep","name":"Check installed service","text":"The installer registers a Windows service by default. Open Services (services.msc) and find PostgreSQL."},
{"@type":"HowToStep","name":"Set startup type","text":"Open the service Properties → General → set Startup type to Automatic (Delayed Start) for stability after boot."},
{"@type":"HowToStep","name":"Choose log on account","text":"In the Log On tab, select the account the service runs under. A dedicated local account with least privileges is recommended."},
{"@type":"HowToStep","name":"Configure recovery","text":"In the Recovery tab, set First/Second failure actions to Restart the Service and specify a reasonable Restart service after delay."},
{"@type":"HowToStep","name":"Start and test","text":"Apply changes, start/restart the service, then connect locally with client tools to verify."}
]
},
{
"@type": "FAQPage",
"mainEntity": [
{"@type": "Question", "name": "How do I make PostgreSQL start on boot?", "acceptedAnswer": {"@type":"Answer","text":"Open Services → PostgreSQL → Properties → set Startup type to Automatic (or Automatic (Delayed Start)) and apply."}},
{"@type": "Question", "name": "Which account should the service run under?", "acceptedAnswer": {"@type":"Answer","text":"Use a dedicated local account with least privileges. Avoid running under highly privileged accounts unless necessary."}},
{"@type": "Question", "name": "Where are PostgreSQL logs on Windows?", "acceptedAnswer": {"@type":"Answer","text":"By default, logs are inside the data directory. You can adjust logging settings in postgresql.conf and manage rotation as needed."}},
{"@type": "Question", "name": "How do I change the port after install?", "acceptedAnswer": {"@type":"Answer","text":"Update the port in postgresql.conf, apply changes, and restart the Windows service. Ensure firewall rules allow the chosen port."}}
]
}
]
}
</script>
</head>
<body>
<header>
<div class="wrap topbar">
<a class="brand" href="https://postgre-sql.github.io/" aria-label="PostgreSQL for Windows — home">
<svg aria-hidden="true"><use href="#icon-check"></use></svg>
<span>PostgreSQL for Windows</span>
</a>
<nav aria-label="Primary navigation">
<ul>
<li><a href="https://postgre-sql.github.io/download-windows.html"><svg width="16" height="16" aria-hidden="true"><use href="#icon-download"></use></svg> Download</a></li>
<li><a href="https://postgre-sql.github.io/offline-installer.html">Offline installer</a></li>
<li><a href="https://postgre-sql.github.io/odbc-driver-x64-x86.html">ODBC x64/x86</a></li>
<li><a href="https://postgre-sql.github.io/configure-windows-service.html">Service</a></li>
<li><a href="https://postgre-sql.github.io/fix-path-issues.html">PATH</a></li>
<li><a href="https://postgre-sql.github.io/migrate-from-older-versions.html">Migrate</a></li>
</ul>
</nav>
</div>
</header>
<div class="wrap breadcrumbs" aria-label="Breadcrumb">
<a href="https://postgre-sql.github.io/">Home</a> · <span>Configure Windows Service</span>
</div>
<section class="hero">
<div class="wrap inner">
<div>
<h1>Run PostgreSQL as a Windows Service</h1>
<p class="sub">The Windows installer registers a service automatically. Tune startup type, service account, and recovery options for a reliable PostgreSQL on Windows 10/11.</p>
<div class="cta-row">
<a class="btn btn-primary" href="https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe" target="_blank" rel="noopener" aria-label="Download PostgreSQL 18.3-3 for Windows (64-bit)"
data-download-url="https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe" data-download-file="postgresql-18.3-3-windows-x64.exe">
<svg width="20" height="20" aria-hidden="true"><use href="#icon-download"></use></svg>
<span>Get the installer</span>
</a>
<a class="btn btn-ghost" href="https://postgre-sql.github.io/download-windows.html">
<svg width="18" height="18" aria-hidden="true"><use href="#icon-external"></use></svg>
<span>Install guide</span>
</a>
</div>
<div class="note" role="note">
<svg width="18" height="18" aria-hidden="true"><use href="#icon-info"></use></svg>
<span>The service name typically includes the version (e.g., a “postgresql-x64-XX” pattern).</span>
</div>
</div>
<div>
<div class="card">
<h3>Quick checklist</h3>
<ul class="list">
<li>Service installed and visible in Services (services.msc).</li>
<li>Startup type set to Automatic (Delayed Start).</li>
<li>Service runs under a least‑privilege account.</li>
<li>Recovery options set to restart on failure.</li>
</ul>
</div>
</div>
</div>
</section>
<main class="wrap">
<section class="section" id="steps">
<h2>Configure via Services (services.msc)</h2>
<div class="card">
<ol class="list">
<li>Open the Windows <strong>Services</strong> console and locate the PostgreSQL service.</li>
<li>Open <strong>Properties → General</strong> and set <strong>Startup type</strong> to <em>Automatic (Delayed Start)</em>.</li>
<li>In <strong>Log On</strong>, select a dedicated account with minimal privileges, and provide credentials if needed.</li>
<li>In <strong>Recovery</strong>, set <em>First failure</em> and <em>Second failure</em> to <em>Restart the Service</em>. Configure the restart delay.</li>
<li>Apply changes, then <strong>Start</strong> or <strong>Restart</strong> the service to validate.</li>
</ol>
</div>
</section>
<section class="section">
<h2>Manual registration (overview)</h2>
<div class="card">
<p class="muted">If you installed PostgreSQL from binaries or need a custom setup, you can register it as a service using supported tools. Ensure the service account has access to the data directory and the executable. Prefer the official installer for simplicity.</p>
</div>
</section>
<section class="section">
<h2>Logs and rotation</h2>
<div class="card-grid">
<div class="card">
<h3><svg width="16" height="16" aria-hidden="true"><use href="#icon-info"></use></svg> Default location</h3>
<p>By default, server logs reside inside the data directory. Check your configuration to confirm the exact path.</p>
</div>
<div class="card">
<h3><svg width="16" height="16" aria-hidden="true"><use href="#icon-info"></use></svg> Rotation basics</h3>
<p>Use built‑in logging settings to rotate logs regularly and avoid large files. Adjust retention to your policy.</p>
</div>
<div class="card">
<h3><svg width="16" height="16" aria-hidden="true"><use href="#icon-warning"></use></svg> Permissions</h3>
<p>Ensure the service account can write to the log directory and the data folder without excessive privileges.</p>
</div>
</div>
</section>
<section class="section">
<h2>Firewall and remote access</h2>
<div class="card">
<p>To allow remote connections, create an inbound rule for the PostgreSQL port (default 5432) in Windows Defender Firewall, and configure client access in your server settings. Limit exposure to trusted networks.</p>
</div>
</section>
<section class="section">
<h2>Troubleshooting — quick answers</h2>
<div class="card-grid">
<div class="card">
<h3><svg width="16" height="16" aria-hidden="true"><use href="#icon-warning"></use></svg> Service won’t start</h3>
<p>Check data directory permissions and verify that configuration paths are correct. Review the latest server logs for details.</p>
</div>
<div class="card">
<h3><svg width="16" height="16" aria-hidden="true"><use href="#icon-warning"></use></svg> Starts, then stops</h3>
<p>Inspect logs for fatal errors. Ensure the port is free and the service account can access required files.</p>
</div>
<div class="card">
<h3><svg width="16" height="16" aria-hidden="true"><use href="#icon-warning"></use></svg> Wrong account</h3>
<p>Switch to a dedicated least‑privilege account in the service Log On tab and restart the service.</p>
</div>
</div>
</section>
<section class="section">
<h2>Related guides</h2>
<div class="card-grid">
<a class="card" href="https://postgre-sql.github.io/download-windows.html" style="text-decoration:none; color:inherit">
<h3>Download & Install</h3>
<p>Install the PostgreSQL server on Windows 10/11.</p>
</a>
<a class="card" href="https://postgre-sql.github.io/fix-path-issues.html" style="text-decoration:none; color:inherit">
<h3>Fix PATH Issues</h3>
<p>Resolve “psql is not recognized” fast.</p>
</a>
<a class="card" href="https://postgre-sql.github.io/offline-installer.html" style="text-decoration:none; color:inherit">
<h3>Offline Installer</h3>
<p>Install PostgreSQL without internet access.</p>
</a>
<a class="card" href="https://postgre-sql.github.io/odbc-driver-x64-x86.html" style="text-decoration:none; color:inherit">
<h3>ODBC Drivers (x64/x86)</h3>
<p>Choose the right psqlODBC and set up a DSN.</p>
</a>
<a class="card" href="https://postgre-sql.github.io/migrate-from-older-versions.html" style="text-decoration:none; color:inherit">
<h3>Migrate from Older Versions</h3>
<p>Backups, pg_upgrade, and post-checks.</p>
</a>
</div>
</section>
<section class="section">
<div class="disclaimer">
<p><strong>Disclaimer:</strong> This is an unofficial resource. PostgreSQL is a registered trademark of the PostgreSQL Community Association of Canada. Links may include affiliate tracking.</p>
</div>
</section>
</main>
<div class="mobile-cta" aria-hidden="true">
<div class="inner">
<span>Need the PostgreSQL installer?</span>
<a class="btn btn-primary" href="https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe" target="_blank" rel="noopener" data-download-url="https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe" data-download-file="postgresql-18.3-3-windows-x64.exe">
<svg width="18" height="18" aria-hidden="true"><use href="#icon-download"></use></svg>
<span>Download</span>
</a>
</div>
</div>
<footer>
<div class="wrap footer-inner">
<div>
<p class="muted">Author: Senior Web Developer & Technical Writer • Unofficial site</p>
<p class="muted">Last updated: <time id="lastUpdated" datetime="">--</time></p>
</div>
<div>
<p class="muted">Need help? Read <a href="https://postgre-sql.github.io/download-windows.html">Install guide</a> or <a href="https://postgre-sql.github.io/fix-path-issues.html">PATH fixes</a>.</p>
</div>
</div>
</footer>
<!-- Cookie banner -->
<div id="cookieBanner" class="cookie-banner" role="dialog" aria-live="polite" aria-label="Cookie consent">
<div class="cookie-content">
<div>
<strong>Cookies & analytics</strong>
<p class="muted" style="margin:6px 0 0">We use minimal analytics to improve this guide. Choose Accept to enable Google Analytics, or Decline to stay anonymous.</p>
</div>
<div class="cookie-actions">
<button class="btn btn-primary" id="cookieAccept">Accept</button>
<button class="btn btn-ghost" id="cookieDecline">Decline</button>
<button class="btn" id="cookieClose" aria-label="Close cookie banner"><svg width="16" height="16" aria-hidden="true"><use href="#icon-close"></use></svg> Close</button>
</div>
</div>
</div>
<script>
(function(){
const FILE_URL = 'https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe';
const FILE_NAME = 'postgresql-18.3-3-windows-x64.exe';
// Bind GA download events to all anchors that specify direct download data attributes
function bindDownloadEvents(){
document.querySelectorAll('a[data-download-url]').forEach(a => {
a.addEventListener('click', function(){
try {
gtag('event','file_download', {
event_category: 'downloads',
event_label: a.getAttribute('data-download-file') || FILE_NAME,
file_url: a.getAttribute('data-download-url') || FILE_URL
});
} catch(e) {}
}, {passive:true});
});
}
// Cookie consent banner logic
const banner = document.getElementById('cookieBanner');
const btnAccept = document.getElementById('cookieAccept');
const btnDecline = document.getElementById('cookieDecline');
const btnClose = document.getElementById('cookieClose');
function showBanner(){ banner.style.display='block'; }
function hideBanner(){ banner.style.display='none'; }
function applyStoredConsent(){
const saved = localStorage.getItem('ga_consent');
if(saved === 'granted'){
gtag('consent','update', {'analytics_storage':'granted','ad_storage':'denied'});
hideBanner();
} else if(saved === 'denied'){
gtag('consent','update', {'analytics_storage':'denied','ad_storage':'denied'});
hideBanner();
} else {
const closed = sessionStorage.getItem('cookie_banner_closed');
if(!closed) showBanner();
}
}
btnAccept.addEventListener('click', function(){
localStorage.setItem('ga_consent','granted');
gtag('consent','update', {'analytics_storage':'granted','ad_storage':'denied'});
hideBanner();
});
btnDecline.addEventListener('click', function(){
localStorage.setItem('ga_consent','denied');
gtag('consent','update', {'analytics_storage':'denied','ad_storage':'denied'});
hideBanner();
});
btnClose.addEventListener('click', function(){
sessionStorage.setItem('cookie_banner_closed','1');
hideBanner();
});
// Update visible last updated and meta
const last = new Date(document.lastModified || '2026-05-01T13:06:51Z');
const lastISO = last.toISOString();
const lastEl = document.getElementById('lastUpdated');
if(lastEl){ lastEl.textContent = last.toLocaleDateString(undefined, {year:'numeric', month:'short', day:'2-digit'}); lastEl.setAttribute('datetime', lastISO); }
const metaLM = document.querySelector('meta[name="last-modified"]');
if(metaLM){ metaLM.setAttribute('content', lastISO); }
bindDownloadEvents();
applyStoredConsent();
})();
</script>
</body>
</html>