Skip to content

Commit

Permalink
old changes out on the server
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Jul 13, 2018
1 parent b7ef6b8 commit 71aebef
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -21,8 +21,8 @@ Start Miner (You will want to run multiple instances of this):
npm run miner
```

Start Frontend
Start Frontend (port 80 might not be the best idea)
```
cd app
npm start
sudo npm start
```
2 changes: 1 addition & 1 deletion app/package.json
Expand Up @@ -13,7 +13,7 @@
"react-stack-grid": "^0.7.1"
},
"scripts": {
"start": "react-scripts start",
"start": "PORT=80 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
Expand Down
10 changes: 5 additions & 5 deletions app/src/App.js
Expand Up @@ -9,7 +9,7 @@ import '../node_modules/antd/dist/antd.css';

const Option = Select.Option;

const backend = "http://localhost:48725"
const backend = ":8000"

let loadInterval
class App extends Component {
Expand All @@ -32,14 +32,14 @@ class App extends Component {
clearInterval(loadInterval)
}
load(){
axios.get(backend)
axios.get("http://"+window.location.hostname+backend)
.then(res => {
this.setState(res.data)
});
}
handleMiningChange(value) {
this.setState({target:value,results:"",priv:"",pub:"",diff:""})
axios.post(backend+'/target', {
axios.post("http://"+window.location.hostname+backend+'/target', {
target:value,
})
.then(function (response) {
Expand Down Expand Up @@ -73,7 +73,7 @@ class App extends Component {
});
var formData = new FormData();
formData.append("image", files[0]);
axios.post(backend+'/upload', formData, {
axios.post("http://"+window.location.hostname+backend+'/upload', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
Expand Down Expand Up @@ -145,7 +145,7 @@ class App extends Component {
let targetImage
if(this.state.target!="none"){
targetImage=(
<img src={backend+"/"+this.state.target} style={{zIndex:-1,marginLeft:80,transform:'scale(10)'}}/>
<img src={"http://"+window.location.hostname+backend+"/"+this.state.target} style={{zIndex:-1,marginLeft:80,transform:'scale(10)'}}/>
)

result = (
Expand Down
6 changes: 3 additions & 3 deletions mine.js
@@ -1,8 +1,8 @@
var fs = require("fs")
let mine;
const iterations = 300
const iterations = 10000
let doMine = async function(){
//while(true){
while(true){
delete require.cache[require.resolve('./modules/miner.js')]
mine = require("./modules/miner.js")
let targetFile = fs.readFileSync("target.txt").toString().trim();
Expand All @@ -13,7 +13,7 @@ let doMine = async function(){
console.log("Mining Image",targetFile)
await mine(targetFile,iterations)
}
//}
}
}
function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -17,6 +17,7 @@
"express": "^4.16.3",
"get-pixels": "^3.3.0",
"hsl-to-rgb": "^1.0.0",
"react-blockies": "^1.2.2"
"react-blockies": "^1.2.2",
"sharp": "^0.20.0"
}
}
14 changes: 14 additions & 0 deletions provisionUbuntu.sh
@@ -0,0 +1,14 @@
#!/bin/bash
sudo apt-get update
sudo apt-get dist-upgrade -y
sudo apt-get upgrade -y
sudo apt-get install build-essential -y
sudo apt-get install python -y
sudo apt-get install -y htop
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
npm install
cd app npm install
cd ..
sudo rm /etc/rc.local
sudo ln -s rc.local /etc/rc.local
10 changes: 5 additions & 5 deletions server.js
Expand Up @@ -64,11 +64,11 @@ app.route('/upload')
/*.resize(8,8,{
kernel: sharp.kernel.nearest
})*/
.resize(32,32,{
kernel: sharp.kernel.cubic
}).sharpen(1,1,8).resize(8,8,{
.sharpen().resize(16,16,{
kernel: sharp.kernel.cubic
}).sharpen(1,1,16)
}).sharpen().resize(8,8,{
kernel: sharp.kernel.cubic
}).sharpen()
/*.resize(8,8,{
kernel: sharp.kernel.lanczos2
})*/
Expand All @@ -86,4 +86,4 @@ app.route('/upload')
});
});

app.listen(48725, () => console.log('Backend listening on 48725!'))
app.listen(8000, () => console.log('Backend listening on 8000!'))

0 comments on commit 71aebef

Please sign in to comment.