Skip to content

Commit b7bbcb3

Browse files
committed
feat: add windows-rdp-keepalive module
1 parent 50c199d commit b7bbcb3

File tree

5 files changed

+114
-10
lines changed

5 files changed

+114
-10
lines changed

LICENSE.txt

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
License text copyright (c) 2020 MariaDB Corporation Ab, All Rights Reserved.
2+
"Business Source License" is a trademark of MariaDB Corporation Ab.
3+
4+
Parameters
5+
6+
Licensor: HashiCorp, Inc.
7+
Licensed Work: Terraform Version 1.6.0 or later. The Licensed Work is (c) 2024
8+
HashiCorp, Inc.
9+
Additional Use Grant: You may make production use of the Licensed Work, provided
10+
Your use does not include offering the Licensed Work to third
11+
parties on a hosted or embedded basis in order to compete with
12+
HashiCorp's paid version(s) of the Licensed Work. For purposes
13+
of this license:
14+
15+
A "competitive offering" is a Product that is offered to third
16+
parties on a paid basis, including through paid support
17+
arrangements, that significantly overlaps with the capabilities
18+
of HashiCorp's paid version(s) of the Licensed Work. If Your
19+
Product is not a competitive offering when You first make it
20+
generally available, it will not become a competitive offering
21+
later due to HashiCorp releasing a new version of the Licensed
22+
Work with additional capabilities. In addition, Products that
23+
are not provided on a paid basis are not competitive.
24+
25+
"Product" means software that is offered to end users to manage
26+
in their own environments or offered as a service on a hosted
27+
basis.
28+
29+
"Embedded" means including the source code or executable code
30+
from the Licensed Work in a competitive offering. "Embedded"
31+
also means packaging the competitive offering in such a way
32+
that the Licensed Work must be accessed or downloaded for the
33+
competitive offering to operate.
34+
35+
Hosting or using the Licensed Work(s) for internal purposes
36+
within an organization is not considered a competitive
37+
offering. HashiCorp considers your organization to include all
38+
of your affiliates under common control.
39+
40+
For binding interpretive guidance on using HashiCorp products
41+
under the Business Source License, please visit our FAQ.
42+
(https://www.hashicorp.com/license-faq)
43+
Change Date: Four years from the date the Licensed Work is published.
44+
Change License: MPL 2.0
45+
46+
For information about alternative licensing arrangements for the Licensed Work,
47+
please contact licensing@hashicorp.com.
48+
49+
Notice
50+
51+
Business Source License 1.1
52+
53+
Terms
54+
55+
The Licensor hereby grants you the right to copy, modify, create derivative
56+
works, redistribute, and make non-production use of the Licensed Work. The
57+
Licensor may make an Additional Use Grant, above, permitting limited production use.
58+
59+
Effective on the Change Date, or the fourth anniversary of the first publicly
60+
available distribution of a specific version of the Licensed Work under this
61+
License, whichever comes first, the Licensor hereby grants you rights under
62+
the terms of the Change License, and the rights granted in the paragraph
63+
above terminate.
64+
65+
If your use of the Licensed Work does not comply with the requirements
66+
currently in effect as described in this License, you must purchase a
67+
commercial license from the Licensor, its affiliated entities, or authorized
68+
resellers, or you must refrain from using the Licensed Work.
69+
70+
All copies of the original and modified Licensed Work, and derivative works
71+
of the Licensed Work, are subject to this License. This License applies
72+
separately for each version of the Licensed Work and the Change Date may vary
73+
for each version of the Licensed Work released by Licensor.
74+
75+
You must conspicuously display this License on each original or modified copy
76+
of the Licensed Work. If you receive the Licensed Work in original or
77+
modified form from a third party, the terms and conditions set forth in this
78+
License apply to your use of that work.
79+
80+
Any use of the Licensed Work in violation of this License will automatically
81+
terminate your rights under this License for the current and all other
82+
versions of the Licensed Work.
83+
84+
This License does not grant you any right in any trademark or logo of
85+
Licensor or its affiliates (provided that you may use a trademark or logo of
86+
Licensor as expressly required by this License).
87+
88+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
89+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
90+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
91+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
92+
TITLE.

bun.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"lockfileVersion": 1,
3+
"configVersion": 0,
34
"workspaces": {
45
"": {
56
"name": "registry",
Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1-
# Windows RDP Keep Alive
1+
# Windows RDP Keep Alive Module
22

3-
This module runs a background script on Windows workspaces that detects active RDP sessions and prevents the workspace from shutting down due to inactivity.
3+
**Status:** Beta (Tested on Windows Server)
44

5-
## Usage
5+
This module adds a background process designed to keep Windows Coder workspaces active during RDP sessions.
6+
7+
When an RDP session is active, the Coder agent may trigger an inactivity shutdown based on low CPU/network use. This module prevents shutdown by injecting a background PowerShell loop (`coder_script`).
8+
9+
The script monitors commands (`query user` or similar) to detect active RDP sessions (`rdp-tcp` in `Active` state). When detected, it generates standard output to simulate activity, resetting the Coder agent's idleness timer.
10+
11+
## Variables
12+
13+
| Name | Description | Default |
14+
| ---------- | ------------------------------------------------- | ------- |
15+
| `interval` | Interval in seconds to check for RDP connections. | `60` |
16+
17+
## Usage Example
618

719
```hcl
8-
module "rdp_keepalive" {
9-
source = "[registry.coder.com/modules/windows-rdp-keepalive/coder](https://registry.coder.com/modules/windows-rdp-keepalive/coder)"
10-
version = "1.0.0"
20+
module "windows_rdp_keepalive" {
21+
source = "[https://registry.coder.com/modules/windows-rdp-keepalive](https://registry.coder.com/modules/windows-rdp-keepalive)"
1122
agent_id = coder_agent.main.id
12-
}
23+
interval = 300 # Check every 5 minutes
24+
}
25+
```

modules/windows-rdp-keepalive/main.tf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ resource "coder_script" "rdp_keepalive" {
2424
display_name = "RDP Keep Alive"
2525
icon = "/icon/remote-desktop.svg"
2626
run_on_start = true
27-
27+
2828
# We run a PowerShell loop in the background
2929
script = <<EOT
3030
$Interval = ${var.interval}
@@ -37,8 +37,6 @@ while ($true) {
3737
3838
if ($rdpSession) {
3939
# RDP is active. We need to generate 'activity' to prevent shutdown.
40-
# Since Coder monitors network/ssh, the simplest way to bump activity
41-
# is to simulate a state change or write to stdout which the agent captures.
4240
4341
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
4442
Write-Host "[$timestamp] RDP Active - Sending KeepAlive signal"

terraform.exe

98.1 MB
Binary file not shown.

0 commit comments

Comments
 (0)