Compare commits

..

11 Commits

Author SHA1 Message Date
Asher
ef069d9b0e Update nbin
The latest version contains a fix for passing null options when reading
a file. Fixes #544.
2019-09-16 18:04:41 -05:00
Asher
6a864f9f47 Make websocket upgrade check case-insensitive
Fixes #925.
2019-09-16 15:05:45 -05:00
Asher
5c16399810 Fix accessing versioned resource using file service
Fixes #986.
2019-09-16 15:05:44 -05:00
Ayane Satomi
0141ded35d [doc/quickstart] add init docs (#981)
Add init docs so people have an idea what to do when starting up a service.

Resolves GH-947
2019-09-16 15:05:25 -05:00
Asher
bb46e80d44 Fix extensions that try to load from node_modules.asar
Should allow manual installation of bracket pair colorizer 2: #544.
2019-09-13 13:07:50 -05:00
Asher
1bd5eca73d Don't terminate extension host on a timeout
We will clean it up on our end if necessary. This allows reconnections
after any length of time.
2019-09-13 11:24:15 -05:00
Asher
48a97abe1d Fix Firefox scrolling
Fixes #976.
2019-09-13 10:42:59 -05:00
Asher
0ff8a11c7f Vsix upload should work 2019-09-13 10:22:07 -05:00
Asher
8b1cdaa4a1 Nbin is no longer a global dependency 2019-09-13 10:20:35 -05:00
Asher
0bbaa9763b Add back Digital Ocean button 2019-09-13 10:17:27 -05:00
Asher
dbe5f23e21 Fix Docker image not building
It seems to copy the entire directory to the second container for some
reason and runs out of space.
2019-09-12 17:24:59 -05:00
11 changed files with 160 additions and 72 deletions

View File

@@ -9,3 +9,4 @@ doc
LICENSE
README.md
node_modules
release

View File

@@ -16,7 +16,9 @@ COPY . .
RUN yarn \
&& MINIFY=true yarn build "${vscodeVersion}" "${codeServerVersion}" \
&& yarn binary "${vscodeVersion}" "${codeServerVersion}" \
&& mv "/src/build/code-server${codeServerVersion}-vsc${vscodeVersion}-linux-x86_64-built/code-server${codeServerVersion}-vsc${vscodeVersion}-linux-x86_64" /src/build/code-server
&& mv "/src/build/code-server${codeServerVersion}-vsc${vscodeVersion}-linux-x86_64-built/code-server${codeServerVersion}-vsc${vscodeVersion}-linux-x86_64" /src/build/code-server \
&& rm -r /src/build/vscode-* \
&& rm -r /src/build/code-server*-linux-*
# We deploy with ubuntu so that devs have a familiar environment.
FROM ubuntu:18.04

View File

@@ -30,6 +30,9 @@ you need to add `--security-opt seccomp=unconfined` to your `docker run`
arguments when launching code-server with Docker. See
[#725](https://github.com/cdr/code-server/issues/725) for details.
### Digital Ocean
[![Create a Droplet](./doc/assets/droplet.svg)](https://marketplace.digitalocean.com/apps/code-server?action=deploy)
### Binaries
1. [Download a binary](https://github.com/cdr/code-server/releases). (Linux and
OS X supported. Windows coming soon)
@@ -43,7 +46,6 @@ arguments when launching code-server with Docker. See
- If you also plan on developing, set the `OUT` environment variable. Otherwise
it will build in this directory which will cause issues because `yarn watch`
will try to compile the build directory as well.
- For now `@coder/nbin` is a global dependency.
- Run `yarn build ${vscodeVersion} ${codeServerVersion}` in this directory (for
example: `yarn build 1.36.0 development`).
- If you target the same VS Code version our Travis builds do everything will
@@ -54,7 +56,6 @@ arguments when launching code-server with Docker. See
code into a single binary.
## Known Issues
- Uploading .vsix files doesn't work.
- Creating custom VS Code extensions and debugging them doesn't work.
- Extension profiling and tips are currently disabled.

24
doc/assets/droplet.svg Normal file
View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="200px" height="40px" viewBox="0 0 200 40" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 52.5 (67469) - http://www.bohemiancoding.com/sketch -->
<title>do-btn-blue-ghost</title>
<desc>Created with Sketch.</desc>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Partner-welcome-kit-Copy-3" transform="translate(-651.000000, -828.000000)">
<g id="do-btn-blue-ghost" transform="translate(651.000000, 828.000000)">
<rect id="Rectangle-Copy-4" stroke="#0069FF" x="0.5" y="0.5" width="199" height="39" rx="6"></rect>
<path d="M6,0 L47,0 L47,40 L6,40 C2.6862915,40 4.05812251e-16,37.3137085 0,34 L-8.8817842e-16,6 C-1.29399067e-15,2.6862915 2.6862915,6.08718376e-16 6,0 Z" id="Rectangle-Copy-5" fill="#0069FF"></path>
<g id="DO_Logo_horizontal_blue-Copy-3" transform="translate(13.000000, 10.000000)" fill="#FFFFFF">
<path d="M10.0098493,20 L10.0098493,16.1262429 C14.12457,16.1262429 17.2897398,12.0548452 15.7269372,7.74627862 C15.1334679,6.14538921 13.8674,4.86072487 12.2650328,4.28756693 C7.952489,2.72620566 3.87733294,5.88845634 3.87733294,9.99938223 C3.87733294,9.99938223 3.87733294,9.99938223 3.87733294,9.99938223 L0,9.99938223 C0,3.45747613 6.3303395,-1.64165309 13.1948014,0.492866119 C16.2017127,1.42177726 18.57559,3.81322933 19.5053586,6.79760341 C21.6418482,13.6754986 16.5577943,20 10.0098493,20 Z" id="XMLID_49_"></path>
<polygon id="XMLID_47_" points="9.52380952 16.1904762 5.71428571 16.1904762 5.71428571 12.3809524 5.71428571 12.3809524 9.52380952 12.3809524 9.52380952 12.3809524"></polygon>
<polygon id="XMLID_46_" points="6.66666667 19.047619 3.80952381 19.047619 3.80952381 19.047619 3.80952381 16.1904762 6.66666667 16.1904762"></polygon>
<polygon id="XMLID_45_" points="3.80952381 16.1904762 0.952380952 16.1904762 0.952380952 16.1904762 0.952380952 13.3333333 0.952380952 13.3333333 3.80952381 13.3333333 3.80952381 13.3333333"></polygon>
</g>
<!-- Modified to add GitHub font-family after DigitalOcean's font-family, otherwise it looks bad on GitHub -->
<text id="Create-a-Droplet-Copy-3" font-family="Sailec-Medium, Sailec, -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol" font-size="16" font-weight="400" fill="#0069FF">
<tspan x="58" y="26">Create a Droplet</tspan>
</text>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -46,12 +46,66 @@ server {
RewriteRule /(.*) http://localhost:8080/$1 [P,L]
ProxyRequests off
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Port 443
ProxyPass / http://localhost:8080/ nocanon
ProxyPass / http://localhost:8080/ nocanon
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
```
### Run automatically at startup
In some cases you might need to run code-server automatically once the host starts. You may use your local init service to do so.
#### Systemd
```ini
[Unit]
Description=VSCode in a browser
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/code-server $(pwd)
WorkingDirectory=$HOME/projects
ExecStop=/sbin/start-stop-daemon --stop -x /usr/bin/code-server
Restart=on-failure
User=1000
[Install]
WantedBy=multi-user.target
```
#### OpenRC
```sh
#!/sbin/openrc-run
depend() {
after net-online
need net
}
supervisor=supervise-daemon
name="code-server"
command="/opt/cdr/code-server"
command_args=""
pidfile="/var/run/cdr.pid"
respawn_delay=5
set -o allexport
if [ -f /etc/environment ]; then source /etc/environment; fi
set +o allexport
```
#### Kubernetes/Docker
Make sure you set your restart policy to always - this will ensure your container starts as the daemon starts.

View File

@@ -14,7 +14,7 @@
"patch:apply": "yarn ensure-in-vscode && cd ../../../ && git apply ./src/vs/server/scripts/vscode.patch"
},
"devDependencies": {
"@coder/nbin": "^1.2.0",
"@coder/nbin": "^1.2.2",
"@types/pem": "^1.9.5",
"@types/safe-compare": "^1.1.0",
"@types/tar-fs": "^1.16.1",

View File

@@ -57,27 +57,27 @@ index 6bb695db68..ecbabe5dc8 100644
}
-
diff --git a/src/vs/base/browser/mouseEvent.ts b/src/vs/base/browser/mouseEvent.ts
index 4c7295e3b9..fc9694a18b 100644
index 4c7295e3b9..b0af2cdd62 100644
--- a/src/vs/base/browser/mouseEvent.ts
+++ b/src/vs/base/browser/mouseEvent.ts
@@ -158,7 +158,7 @@ export class StandardWheelEvent {
// vertical delta scroll
if (typeof e1.wheelDeltaY !== 'undefined') {
@@ -160,6 +160,8 @@ export class StandardWheelEvent {
this.deltaY = e1.wheelDeltaY / 120;
- } else if (typeof e2.VERTICAL_AXIS !== 'undefined' && e2.axis === e2.VERTICAL_AXIS) {
+ } else if (browser.isFirefox || (typeof e2.VERTICAL_AXIS !== 'undefined' && e2.axis === e2.VERTICAL_AXIS)) {
} else if (typeof e2.VERTICAL_AXIS !== 'undefined' && e2.axis === e2.VERTICAL_AXIS) {
this.deltaY = -e2.detail / 3;
+ } else if (browser.isFirefox) {
+ this.deltaY = -e.deltaY / 3;
} else {
this.deltaY = -e.deltaY / 40;
@@ -171,7 +171,7 @@ export class StandardWheelEvent {
} else {
this.deltaX = e1.wheelDeltaX / 120;
}
@@ -173,6 +175,8 @@ export class StandardWheelEvent {
}
- } else if (typeof e2.HORIZONTAL_AXIS !== 'undefined' && e2.axis === e2.HORIZONTAL_AXIS) {
+ } else if (browser.isFirefox || (typeof e2.HORIZONTAL_AXIS !== 'undefined' && e2.axis === e2.HORIZONTAL_AXIS)) {
} else if (typeof e2.HORIZONTAL_AXIS !== 'undefined' && e2.axis === e2.HORIZONTAL_AXIS) {
this.deltaX = -e.detail / 3;
+ } else if (browser.isFirefox) {
+ this.deltaX = -e.deltaX / 3;
} else {
this.deltaX = -e.deltaX / 40;
}
diff --git a/src/vs/base/common/network.ts b/src/vs/base/common/network.ts
index 4f93e06df0..ae63e64a7f 100644
--- a/src/vs/base/common/network.ts
@@ -1032,37 +1032,33 @@ index 7c3b6ae53e..18dec6effa 100644
get webviewResourceRoot(): string {
diff --git a/src/vs/workbench/services/extensions/node/extensionHostProcessSetup.ts b/src/vs/workbench/services/extensions/node/extensionHostProcessSetup.ts
index 6d31b177ac..a586ac7466 100644
index 6d31b177ac..67c955a59d 100644
--- a/src/vs/workbench/services/extensions/node/extensionHostProcessSetup.ts
+++ b/src/vs/workbench/services/extensions/node/extensionHostProcessSetup.ts
@@ -116,7 +116,7 @@ function _createExtHostProtocol(): Promise<IMessagePassingProtocol> {
protocol.onClose(() => onTerminate());
resolve(protocol);
@@ -41,12 +41,12 @@ const args = minimist(process.argv.slice(2), {
const Module = require.__$__nodeRequire('module') as any;
const originalLoad = Module._load;
- if (msg.skipWebSocketFrames) {
+ // if (msg.skipWebSocketFrames) {
// Wait for rich client to reconnect
- Module._load = function (request: string) {
+ Module._load = function (request: string, parent: object, isMain: boolean) {
if (request === 'natives') {
throw new Error('Either the extension or a NPM dependency is using the "natives" node module which is unsupported as it can cause a crash of the extension host. Click [here](https://go.microsoft.com/fwlink/?linkid=871887) to find out more');
}
- return originalLoad.apply(this, arguments);
+ return originalLoad.apply(this, [request.replace(/node_modules\.asar(\.unpacked)?/, 'node_modules'), parent, isMain]);
};
})();
@@ -128,7 +128,7 @@ function _createExtHostProtocol(): Promise<IMessagePassingProtocol> {
} else {
// Do not wait for web companion to reconnect
protocol.onSocketClose(() => {
// The socket has closed, let's give the renderer a certain amount of time to reconnect
@@ -125,12 +125,12 @@ function _createExtHostProtocol(): Promise<IMessagePassingProtocol> {
onTerminate();
}, ProtocolConstants.ReconnectionGraceTime);
});
- } else {
- // Do not wait for web companion to reconnect
- protocol.onSocketClose(() => {
- onTerminate();
- });
- }
+ // } else {
+ // // Do not wait for web companion to reconnect
+ // protocol.onSocketClose(() => {
+ // onTerminate();
+ // });
+ // }
+ process.send!({ type: 'VSCODE_EXTHOST_DISCONNECTED' });
});
}
}
}
});
diff --git a/src/vs/workbench/workbench.web.main.ts b/src/vs/workbench/workbench.web.main.ts
index 681fc606b6..e34ef5d4bc 100644
--- a/src/vs/workbench/workbench.web.main.ts

View File

@@ -164,8 +164,8 @@ export class FileProviderChannel implements IServerChannel, IDisposable {
private transform(resource: UriComponents): URI {
// Used for walkthrough content.
if (resource.path.indexOf("/static") === 0) {
return URI.file(this.environmentService.appRoot + resource.path.replace(/^\/static/, ""));
if (/^\/static[^/]*\//.test(resource.path)) {
return URI.file(this.environmentService.appRoot + resource.path.replace(/^\/static[^/]*\//, "/"));
// Used by the webview service worker to load resources.
} else if (resource.path === "/vscode-resource" && resource.query) {
try {

View File

@@ -17,10 +17,7 @@ export abstract class Connection {
private disposed = false;
private _offline: number | undefined;
public constructor(protected protocol: Protocol) {
protocol.onClose(() => this.dispose()); // Explicit close.
protocol.onSocketClose(() => this._offline = Date.now()); // Might reconnect.
}
public constructor(protected protocol: Protocol, public readonly token: string) {}
public get offline(): number | undefined {
return this._offline;
@@ -39,6 +36,12 @@ export abstract class Connection {
}
}
protected setOffline(): void {
if (!this._offline) {
this._offline = Date.now();
}
}
/**
* Set up the connection on a new socket.
*/
@@ -50,6 +53,12 @@ export abstract class Connection {
* Used for all the IPC channels.
*/
export class ManagementConnection extends Connection {
public constructor(protected protocol: Protocol, token: string) {
super(protocol, token);
protocol.onClose(() => this.dispose()); // Explicit close.
protocol.onSocketClose(() => this.setOffline()); // Might reconnect.
}
protected doDispose(): void {
this.protocol.sendDisconnect();
this.protocol.dispose();
@@ -66,11 +75,11 @@ export class ExtensionHostConnection extends Connection {
private process?: cp.ChildProcess;
public constructor(
locale:string, protocol: Protocol, buffer: VSBuffer,
locale:string, protocol: Protocol, buffer: VSBuffer, token: string,
private readonly log: ILogService,
private readonly environment: IEnvironmentService,
) {
super(protocol);
super(protocol, token);
this.protocol.dispose();
this.spawn(locale, buffer).then((p) => this.process = p);
this.protocol.getUnderlyingSocket().pause();
@@ -129,6 +138,9 @@ export class ExtensionHostConnection extends Connection {
const severity = (<any>this.log)[event.severity] ? event.severity : "info";
(<any>this.log)[severity]("Extension host", event.arguments);
}
if (event && event.type === "VSCODE_EXTHOST_DISCONNECTED") {
this.setOffline();
}
});
const listen = (message: IExtHostReadyMessage) => {

View File

@@ -279,7 +279,7 @@ export abstract class Server {
// without adding query parameters which have their own issues.
// REVIEW: Discuss whether this is the best option; this is sort of a quick
// hack almost to get caching in the meantime but it does work pretty well.
if (/static-.+/.test(base)) {
if (/^\/static-.+/.test(base)) {
base = "/static";
}
@@ -331,7 +331,7 @@ export abstract class Server {
this.ensureGet(request);
if (!this.authenticate(request)) {
throw new HttpError("Unauthorized", HttpCode.Unauthorized);
} else if (request.headers.upgrade !== "websocket") {
} else if (!request.headers.upgrade || request.headers.upgrade.toLowerCase() !== "websocket") {
throw new Error("HTTP/1.1 400 Bad Request");
}
@@ -449,7 +449,7 @@ export class MainServer extends Server {
public readonly onDidClientConnect = this._onDidClientConnect.event;
private readonly ipc = new IPCServer(this.onDidClientConnect);
private readonly maxOfflineConnections = 5;
private readonly maxExtraOfflineConnections = 0;
private readonly connections = new Map<ConnectionType, Map<string, Connection>>();
private readonly services = new ServiceCollection();
@@ -601,7 +601,7 @@ export class MainServer extends Server {
let connection: Connection;
if (message.desiredConnectionType === ConnectionType.Management) {
connection = new ManagementConnection(protocol);
connection = new ManagementConnection(protocol, token);
this._onDidClientConnect.fire({
protocol, onDidClientDisconnect: connection.onClose,
});
@@ -609,28 +609,26 @@ export class MainServer extends Server {
const buffer = protocol.readEntireBuffer();
connection = new ExtensionHostConnection(
message.args ? message.args.language : "en",
protocol, buffer,
protocol, buffer, token,
this.services.get(ILogService) as ILogService,
this.services.get(IEnvironmentService) as IEnvironmentService,
);
}
connections.set(token, connection);
this.disposeOldOfflineConnections();
connection.onClose(() => connections.delete(token));
this.disposeOldOfflineConnections(connections);
break;
case ConnectionType.Tunnel: return protocol.tunnel();
default: throw new Error("Unrecognized connection type");
}
}
private disposeOldOfflineConnections(): void {
this.connections.forEach((connections) => {
const offline = Array.from(connections.values())
.filter((connection) => typeof connection.offline !== "undefined");
for (let i = 0, max = offline.length - this.maxOfflineConnections; i < max; ++i) {
offline[i].dispose();
}
});
private disposeOldOfflineConnections(connections: Map<string, Connection>): void {
const offline = Array.from(connections.values())
.filter((connection) => typeof connection.offline !== "undefined");
for (let i = 0, max = offline.length - this.maxExtraOfflineConnections; i < max; ++i) {
offline[i].dispose();
}
}
private async initializeServices(args: ParsedArgs): Promise<void> {

View File

@@ -7,10 +7,10 @@
resolved "https://registry.yarnpkg.com/@coder/logger/-/logger-1.1.8.tgz#416a7221d84161ee35eca9cfa93ba9377639b4ee"
integrity sha512-NJDC4rZTx0deVYqAxZtJWACq3IrVR59BjFeZebO3i7OfTZZMkkbLsGsCFMnJd5KnX6KjnvvFq4XXtwJ9yf8/YQ==
"@coder/nbin@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@coder/nbin/-/nbin-1.2.0.tgz#b1cc5ed51193ded98ccfe39825ceee500b90f849"
integrity sha512-fHnOqx1yAuK65gr1D9Du7W4AXiITEcFPKIZ3JifvXMeSSwzdVzq3nvVSCPD45KTwK1nS6pDKkXC/CqrYinUf7Q==
"@coder/nbin@^1.2.2":
version "1.2.2"
resolved "https://registry.yarnpkg.com/@coder/nbin/-/nbin-1.2.2.tgz#c5f9aaa2a0e84c2a13a4cce895547efbd66730b7"
integrity sha512-1Z6aYBRZRY1AQ2xp0jmoz+TXR8M4WaHa9FfVkOPej0KPJjYtEp18I+/6CmffDtBLxSnIai0rc+AA0VhbjCN/rg==
dependencies:
"@coder/logger" "^1.1.8"
fs-extra "^7.0.1"