-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial version of working mongodb gateway
- Loading branch information
Showing
4 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
(c) Copyright 2018 Mind-Flip Limited | ||
Based on the original from Intel (see license and details below). | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
---------------------------------------------------------------------------- | ||
(c) Copyright 2013 Intel Performance Learning Solutions Ltd, | ||
Intel Corporation | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
In addition to the Apache License, Version 2.0, please note that: | ||
This software is subject to the U.S. Export Administration Regulations | ||
and other U.S. law, and may not be exported or re-exported to certain | ||
countries (Cuba, Iran, North Korea, Sudan, and Syria) or to persons or | ||
entities prohibited from receiving U.S. exports (including Denied Parties, | ||
Specially Designated Nationals, and entities on the Bureau of Export | ||
Administration Entity List or involved with missile technology or nuclear, | ||
chemical or biological weapons). | ||
**/ | ||
|
||
var io = require('socket.io').listen(server); | ||
var ioclient = require('socket.io-client'); | ||
var ipaddresses = require('./getlocalip'); | ||
var importedSis = require('../../sis/sisyphus'); | ||
var $sis = importedSis.$sis; | ||
|
||
var myIP = ipaddresses.getIPAddress(); | ||
console.log("my local ip is being used:" + myIP); | ||
|
||
if ( process.argv.length == 3 ) { | ||
console.log("Command line over rule for auto-detected IP address, using \"" + process.argv[2] + "\" instead."); | ||
myIP = process.argv[2]; //"pint.dyndns.info"; | ||
} | ||
|
||
$sis.configureAsGateway( { gateway : "node" }, "http://" + myIP + "/", [], io, ioclient ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
(c) Copyright 2013 Intel Performance Learning Solutions Ltd, Intel Corporation | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
In addition to the Apache License, Version 2.0, please note that: | ||
This software is subject to the U.S. Export Administration Regulations | ||
and other U.S. law, and may not be exported or re-exported to certain | ||
countries (Cuba, Iran, North Korea, Sudan, and Syria) or to persons or | ||
entities prohibited from receiving U.S. exports (including Denied Parties, | ||
Specially Designated Nationals, and entities on the Bureau of Export | ||
Administration Entity List or involved with missile technology or nuclear, | ||
chemical or biological weapons). | ||
**/ | ||
|
||
|
||
function getListOfIPAddresses() { | ||
var retval = new Array(); | ||
var os = require('os'); | ||
var ifaces=os.networkInterfaces(); | ||
console.log("processing interfaces"); | ||
|
||
for(var dev in ifaces) { | ||
var alias =0; | ||
ifaces[dev].forEach(function(details){ | ||
if ( details.family=='IPv4') { | ||
//console.log(dev+(alias?':'+alias:''),details.address); | ||
retval.push(details.address); | ||
alias++; | ||
} | ||
}); | ||
} | ||
|
||
return retval; | ||
} | ||
|
||
function getFirstExternalIpAddress() { | ||
var addresses = getListOfIPAddresses(); | ||
var retval = null; | ||
for(var i =0 ; i < addresses.length; i++) { | ||
if ( addresses[i] != '127.0.0.1' ) { | ||
retval = addresses[i]; | ||
break; | ||
} | ||
} | ||
return retval; | ||
} | ||
|
||
|
||
function getWorkableIPAddress() { | ||
var address = getFirstExternalIpAddress(); | ||
if ( address == null ) { | ||
addreess = '127.0.0.1'; | ||
} | ||
return address; | ||
} | ||
|
||
if ( typeof(exports) != 'undefined' ) { | ||
exports.getIPAddress = getWorkableIPAddress; | ||
} |
16 changes: 16 additions & 0 deletions
16
examples/mongodb_gateway/install_npm_packages_for_mongodb_gateway.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
function print { | ||
echo -e "\e[36m$1\e[0m" | ||
} | ||
|
||
print "Install express" | ||
sudo npm install express | ||
print "Install socket.io" | ||
sudo npm install socket.io | ||
sudo npm install socket.io-client | ||
print "Installing Q, for node" | ||
sudo npm install q | ||
print "Installing mongodb for node" | ||
sudo npm install mongodb | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
|
||
############################################################################### | ||
# (c) Copyright 2018 Mind-Flip Limited | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy of | ||
# the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# | ||
################################################################################ | ||
|
||
|
||
function print { | ||
echo -e "\e[36m$1\e[0m" | ||
} | ||
|
||
function print_green { | ||
echo -e "\e[92m$1\e[0m" | ||
} | ||
|
||
|
||
|
||
function step { | ||
LAST_STEP="$1" | ||
print "$1" | ||
} | ||
|
||
function step_done { | ||
print_green "$LAST_STEP finished." | ||
} | ||
|
||
function print_title { | ||
print "Running Sisyphus Distributed Compute as Gateway" | ||
print "==================================================" | ||
print "Notes:" | ||
print " * Running 'nodejs' (based on Ubuntu)." | ||
print " * Runs web server (Express) on port 80 and" | ||
print " therefore requires sudo." | ||
print "Please ensure that the installation steps outlined" | ||
print "in the readme.md file within the 'sis' directory " | ||
print "have been followed. " | ||
} | ||
|
||
print_title | ||
|
||
sudo nodejs ./gateway.js | ||
|