Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GCI] Add windows support #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions src/services/azure-functions/azure-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ const chalk = require("chalk");
const tar = require("tar-fs");

let docker;
if(process.platform != 'win32'){

if (process.platform === "win32") {
docker = new Docker({
socketPath: "/var/run/docker.sock"
socketPath: "//./pipe/docker_engine",
});
} else {
docker = new Docker({
socketPath: "//./pipe/docker_engine"
})
}
socketPath: "/var/run/docker.sock",
});
}

let workingDir = "./example/azure-functions/";
let folder;
Expand All @@ -37,14 +38,14 @@ class AzureFunction extends CloudLocal {
{
t: "azure-functions-image"
},
function(err, stream) {
function (err, stream) {
stream.pipe(
process.stdout,
{
end: true
}
);
stream.on("end", function() {
stream.on("end", function () {
customTerminal();
});
}
Expand All @@ -53,10 +54,10 @@ class AzureFunction extends CloudLocal {
}

function customTerminal(container) {
setTimeout(function() {
setTimeout(function () {
console.log("$ Clocal >");
let stdin = process.openStdin();
stdin.addListener("data", function(d) {
stdin.addListener("data", function (d) {
let inputService = d.toString().trim();
if (
inputService == "clocal function-start" ||
Expand All @@ -81,12 +82,12 @@ function startContainer() {
"80/tcp": [{ HostPort: "9574" }]
}
},
function(err, container) {
function (err, container) {
if (err) {
console.log(err);
return;
}
container.start({}, function(err, data) {
container.start({}, function (err, data) {
if (err) {
console.log(err);
return;
Expand All @@ -108,7 +109,7 @@ function startContainer() {
%

\nNow listening on: http://localhost:9574` +
` Clocal function-stop to shut down.\nNote: Currently HTTP Trigger functions working.`
` Clocal function-stop to shut down.\nNote: Currently HTTP Trigger functions working.`
)
);
runExec(container);
Expand All @@ -128,12 +129,12 @@ function runExec(container) {
Tty: true
};

container.exec(options, function(err, exec) {
container.exec(options, function (err, exec) {
if (err) {
console.log(err);
return;
}
exec.start(function(err, stream) {
exec.start(function (err, stream) {
if (err) {
console.log(err);
return;
Expand All @@ -144,10 +145,10 @@ function runExec(container) {
}

function removeContainer() {
docker.listContainers(function(err, containers) {
containers.forEach(function(containerInfo) {
docker.listContainers(function (err, containers) {
containers.forEach(function (containerInfo) {
docker.getContainer(containerInfo.Id).kill(containerInfo.Id);
setTimeout(function() {
setTimeout(function () {
console.log("Functions container stopped");
return process.exit(0);
}, 5000);
Expand Down
33 changes: 17 additions & 16 deletions src/services/azure-storage/azure-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ const CloudLocal = require("./../azure/cloud-local");
const Docker = require("dockerode");

let docker;
if(process.platform != 'win32'){

if (process.platform === "win32") {
docker = new Docker({
socketPath: "/var/run/docker.sock"
socketPath: "//./pipe/docker_engine",
});
} else {
docker = new Docker({
socketPath: "//./pipe/docker_engine"
})
}
socketPath: "/var/run/docker.sock",
});
}

// let commandHandlers = {"storage": {"clear": clearFiles, "stop": removeContainer }}
let commandHandlers = {
Expand Down Expand Up @@ -40,12 +41,12 @@ class AzureStorage extends CloudLocal {
"10002/tcp": [{ HostPort: "9571" }]
}
},
function(err, container) {
function (err, container) {
if (err) {
console.log(err);
return;
}
container.start({}, function(err, data) {
container.start({}, function (err, data) {
if (err) {
console.log(err);
return;
Expand All @@ -64,12 +65,12 @@ function runExec(container) {
AttachStderr: true
};

container.exec(options, function(err, exec) {
container.exec(options, function (err, exec) {
if (err) {
console.log(err);
return;
}
exec.start(function(err, stream) {
exec.start(function (err, stream) {
if (err) {
console.log(err);
return;
Expand All @@ -83,10 +84,10 @@ function runExec(container) {
}

function customTerminal(container) {
setTimeout(function() {
setTimeout(function () {
console.log("$ Clocal >");
let stdin = process.openStdin();
stdin.addListener("data", function(d) {
stdin.addListener("data", function (d) {
let inputService = d.toString().trim();
if (
inputService == "clocal storage-stop" ||
Expand All @@ -104,10 +105,10 @@ function customTerminal(container) {
}

function removeContainer() {
docker.listContainers(function(err, containers) {
containers.forEach(function(containerInfo) {
docker.listContainers(function (err, containers) {
containers.forEach(function (containerInfo) {
docker.getContainer(containerInfo.Id).kill(containerInfo.Id);
setTimeout(function() {
setTimeout(function () {
console.log("Storage container stopped");
return process.exit(0);
}, 5000);
Expand Down Expand Up @@ -153,12 +154,12 @@ function clearFiles(container) {
AttachStdout: true,
AttachStderr: true
};
container.exec(options, function(err, exec) {
container.exec(options, function (err, exec) {
if (err) {
console.log(err);
return;
}
exec.start(function(err, stream) {
exec.start(function (err, stream) {
if (err) {
console.log(err);
return;
Expand Down