Skip to content

Commit 6978717

Browse files
feat: redirect stdout/stderr to log file
1 parent 05894ea commit 6978717

File tree

6 files changed

+34
-1
lines changed

6 files changed

+34
-1
lines changed

src/code-server/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ VS Code in the browser
2828
| disableWorkspaceTrust | Disable Workspace Trust feature. This only affects the current session. | boolean | false |
2929
| extensions | Comma-separated list of VS Code extensions to install. Format: 'publisher.extension[@version]' (e.g., 'ms-python.python,ms-azuretools.vscode-docker'). | string | - |
3030
| host | The address to bind to for the code-server. Use '0.0.0.0' to listen on all interfaces. | string | 127.0.0.1 |
31+
| logFile | Path to a file to send stdout and stderr logs to from code-server. | string | /tmp/code-server.log |
3132
| port | The port to bind to for the code-server. | string | 8080 |
3233
| socket | Path to a socket. When specified, host and port will be ignored. | string | - |
3334
| socketMode | File mode of the socket when using the socket option. | string | - |

src/code-server/devcontainer-feature.json

+5
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@
7070
"default": "127.0.0.1",
7171
"description": "The address to bind to for the code-server. Use '0.0.0.0' to listen on all interfaces."
7272
},
73+
"logFile": {
74+
"type": "string",
75+
"default": "/tmp/code-server.log",
76+
"description": "Path to a file to send stdout and stderr logs to from code-server."
77+
},
7378
"port": {
7479
"type": "string",
7580
"default": "8080",

src/code-server/install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ if [[ \$(whoami) != "$_REMOTE_USER" ]]; then
8484
else
8585
$(declare -p FLAGS)
8686
87-
code-server "\${FLAGS[@]}" "$CODE_SERVER_WORKSPACE"
87+
code-server "\${FLAGS[@]}" "$CODE_SERVER_WORKSPACE" >"$LOGFILE" 2>&1
8888
fi
8989
EOF
9090

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library bundled with the devcontainer CLI
5+
source dev-container-features-test-lib
6+
7+
# Feature-specific tests
8+
check "code-server version" code-server --version
9+
check "code-server running" pgrep -f 'code-server/lib/node.*/code-server'
10+
check "code-server listening" lsof -i "@0.0.0.0:8080"
11+
12+
check "code-server log-file" test -f /tmp/code-server-log-file.log
13+
check "code-server log-file content" grep "HTTP server listening on http://127.0.0.1:8080/" < /tmp/code-server-log-file.log
14+
15+
# Report results
16+
reportResults

test/code-server/scenarios.json

+8
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,13 @@
160160
"socketMode": "777"
161161
}
162162
}
163+
},
164+
"code-server-log-file": {
165+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
166+
"features": {
167+
"code-server": {
168+
"logFile": "/tmp/code-server-log-file.log"
169+
}
170+
}
163171
}
164172
}

test/code-server/test.sh

+3
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ check "code-server version" code-server --version
99
check "code-server running" pgrep -f 'code-server/lib/node.*/code-server'
1010
check "code-server listening" lsof -i "@127.0.0.1:8080"
1111

12+
check "code-server log-file" test -f /tmp/code-server.log
13+
check "code-server log-file content" grep "HTTP server listening on http://127.0.0.1:8080/" < /tmp/code-server.log
14+
1215
# Report results
1316
reportResults

0 commit comments

Comments
 (0)