Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into support-ollama-api
Browse files Browse the repository at this point in the history
  • Loading branch information
haraldschilly committed Mar 17, 2024
2 parents e4ed26c + a23d2f1 commit 00834d1
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/packages/hub/proxy/handle-upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export default function init(
const re = new RegExp(proxy_regexp);

async function handleProxyUpgradeRequest(req, socket, head): Promise<void> {
socket.on("error", (err) => {
// server will crash sometimes without this:
logger.debug("WARNING -- websocket socket error", err);
});
const dbg = (...args) => {
logger.silly(req.url, ...args);
};
Expand Down
29 changes: 29 additions & 0 deletions src/packages/server/compute/cloud/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,35 @@ set -v
`;
}

// if installHttpsProxy runs, it has to be after installNode
// TODO: A problem with this is for some reason it fails to run below,
// it won't be reported. Also, maybe this should be in some sort
// of official systemd daemon.
// Todo: maybe also nail down the version or tag better. I suspect
// the proxy will get very stable soon.
// This could also just merge with the @cocalc/compute-server package.
export function installHttpsProxy({
IMAGES,
image,
}: {
IMAGES: Images;
image: string;
}) {
const proxy = IMAGES[image]?.proxy;
if (proxy === false) {
return "";
}

return `
set +v
NVM_DIR=/cocalc/nvm source /cocalc/nvm/nvm.sh
set -v
DEBUG=proxy:* PROXY_CONFIG=/cocalc/conf/proxy.json PROXY_AUTH_TOKEN_FILE=/cocalc/conf/auth_token npx -y @cocalc/compute-server-proxy@latest > /var/log/cocalc-proxy.log 2> /var/log/cocalc-proxy.err &
`;
}

export function installMicroK8s({
image,
IMAGES,
Expand Down
4 changes: 4 additions & 0 deletions src/packages/server/compute/cloud/startup-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
installDocker,
installNode,
installCoCalc,
installHttpsProxy,
installConf,
installMicroK8s,
installUser,
Expand Down Expand Up @@ -122,6 +123,9 @@ if [ $? -ne 0 ]; then
exit 1
fi
setState install install-proxy '' 60 55
${installHttpsProxy({ IMAGES, image })}
setState install install-user '' 60 60
${doInstallUser ? installUser() : ""}
if [ $? -ne 0 ]; then
Expand Down
12 changes: 12 additions & 0 deletions src/packages/util/db-schema/compute-servers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ export interface Image {
disabled?: boolean;
// priority -- optional integer used for sorting options to display to user. The bigger the higher.
priority?: number;
// proxy: if false, do NOT run https proxy server on host VM
// if nothing given, runs proxy server with no default config (so does nothing)
// if given, is array of proxy config.
proxy?:
| false
| {
path: string;
target: string;
ws?: boolean;
options?: any;
wsOptions?: any;
}[];
}

export type Images = { [name: string]: Image };
Expand Down

0 comments on commit 00834d1

Please sign in to comment.