Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4fdd243

Browse files
Add linkup command to improve link functionality
1 parent 780991b commit 4fdd243

File tree

7 files changed

+55
-6
lines changed

7 files changed

+55
-6
lines changed

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ vendor/modules
1212
node-*
1313
/plugins
1414
/lib/coder-cloud-agent
15+
/lib/linkup
1516
.home
1617
coverage
1718
**/.DS_Store

‎ci/build/build-code-server.sh‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,29 @@ main() {
1515
chmod +x out/node/entry.js
1616
fi
1717

18+
# for arch; we do not use OS from lib.sh and get our own.
19+
# lib.sh normalizes macos to darwin - but cloud-agent's binaries do not
20+
source ./ci/lib.sh
21+
OS="$(uname | tr '[:upper:]' '[:lower:]')"
22+
1823
if ! [ -f ./lib/coder-cloud-agent ]; then
1924
echo "Downloading the cloud agent..."
2025

21-
# for arch; we do not use OS from lib.sh and get our own.
22-
# lib.sh normalizes macos to darwin - but cloud-agent's binaries do not
23-
source ./ci/lib.sh
24-
OS="$(uname | tr '[:upper:]' '[:lower:]')"
25-
2626
set +e
2727
curl -fsSL "https://github.com/cdr/cloud-agent/releases/latest/download/cloud-agent-$OS-$ARCH" -o ./lib/coder-cloud-agent
2828
chmod +x ./lib/coder-cloud-agent
2929
set -e
3030
fi
3131

32+
if ! [ -f ./lib/linkup ]; then
33+
echo "Downloading Link agent..."
34+
35+
set +e
36+
curl -fsSL "https://storage.googleapis.com/coder-link-releases/latest/linkup-$OS-$ARCH" -o ./lib/linkup
37+
chmod +x ./lib/linkup
38+
set -e
39+
fi
40+
3241
yarn browserify out/browser/register.js -o out/browser/register.browserified.js
3342
yarn browserify out/browser/pages/login.js -o out/browser/pages/login.browserified.js
3443
yarn browserify out/browser/pages/vscode.js -o out/browser/pages/vscode.browserified.js

‎ci/build/build-release.sh‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ EOF
6161
rsync node_modules/ "$RELEASE_PATH/node_modules"
6262
mkdir -p "$RELEASE_PATH/lib"
6363
rsync ./lib/coder-cloud-agent "$RELEASE_PATH/lib"
64+
rsync ./lib/linkup "$RELEASE_PATH/lib"
6465
fi
6566
}
6667

‎ci/build/npm-postinstall.sh‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ main() {
6363
echo "Failed to download cloud agent; --link will not work"
6464
fi
6565

66+
if curl -fsSL "https://storage.googleapis.com/coder-link-releases/latest/linkup-$OS-$ARCH" -o ./lib/linkup; then
67+
chmod +x ./lib/linkup
68+
else
69+
echo "Failed to download Link agent; the Link extension will not work"
70+
fi
71+
6672
if ! vscode_yarn; then
6773
echo "You may not have the required dependencies to build the native modules."
6874
echo "Please see https://github.com/cdr/code-server/blob/master/docs/npm.md"

‎src/node/link.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { logger } from "@coder/logger"
2+
import { spawn } from "child_process"
3+
import path from "path"
4+
5+
export function startLink(port: number): Promise<void> {
6+
logger.debug(`running link targetting ${port}`)
7+
8+
const agent = spawn(path.resolve(__dirname, "../../lib/linkup"), ["--devurl", `code:${port}:code-server`], {
9+
shell: false,
10+
})
11+
return new Promise((res, rej) => {
12+
agent.on("error", rej)
13+
agent.on("close", (code) => {
14+
if (code !== 0) {
15+
return rej({
16+
message: `Link exited with ${code}`,
17+
})
18+
}
19+
res()
20+
})
21+
})
22+
}

‎src/node/main.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { createApp, ensureAddress } from "./app"
88
import { AuthType, DefaultedArgs, Feature } from "./cli"
99
import { coderCloudBind } from "./coder_cloud"
1010
import { commit, version } from "./constants"
11+
import { startLink } from "./link"
1112
import { register } from "./routes"
1213
import { humanPath, isFile, open } from "./util"
1314

@@ -129,6 +130,15 @@ export const runCodeServer = async (args: DefaultedArgs): Promise<http.Server> =
129130
logger.info(" - Connected to cloud agent")
130131
}
131132

133+
try {
134+
const port = parseInt(serverAddress.split(":").pop() as string, 10)
135+
startLink(port).catch((ex) => {
136+
logger.debug("Link daemon exited!", field("error", ex))
137+
})
138+
} catch (ex) {
139+
logger.debug("Failed to start link daemon!", ex)
140+
}
141+
132142
if (args.enable && args.enable.length > 0) {
133143
logger.info("Enabling the following experimental features:")
134144
args.enable.forEach((feature) => {

‎vendor/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"postinstall": "./postinstall.sh"
88
},
99
"devDependencies": {
10-
"code-oss-dev": "cdr/vscode#96a09a7846538c3bbedb6a2aeca729537bb8202b"
10+
"code-oss-dev": "cdr/vscode#17834274b6acc63582c1150fc621c243373ddeb9"
1111
}
1212
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /