Closed Blogshot closed 6 years ago
you can try screen command and detach once you have it running as you want.
screen command
ctrl+a
then d
https://stackoverflow.com/questions/4847691/how-do-i-get-out-of-a-screen-without-typing-exit
You could use the miner programatically instead of using the CLI. That process.stdin.setRawMode
is something from the CLI code, but that shouldn't happen if you use it like this
@cazala Thanks, I made a custom js-Script that can be invoked via node
command. Seems to be working!
@Blogshot just to let you know, this has been fixed in version v1.9.1
, so now you should be able to use the CLI without that process.stdin.setRawMode
error
@Blogshot Could you share the bash you're using please? :smile:
@mariomixtegapach miner
#!/bin/bash
cd /root/coinhive/ && node miner.js > miner.log 2> miner.err &
echo $! > /root/coinhive/miner.pid
miner.js
(async () => {
var fs = require('fs');
fs.writeFile('./miner.pid', process.pid);
// Create miner
const miner = await CoinHive('R5hcEcpv1gWEYZ0CzKy8wuC3W6MczjVh'); // CoinHive's Site Key
// Start miner
await miner.start();
// Listen on events
miner.on('found', () => {
var date = new Date();
console.log("[" + date.toLocaleDateString() + " " + date.toLocaleTimeString() + "] Found!");
});
miner.on('accepted', () => {
var date = new Date();
console.log("[" + date.toLocaleDateString() + " " + date.toLocaleTimeString() + "] Accepted!");
});
miner.on('update', data => {
var date = new Date();
console.log(
"[" + date.toLocaleDateString() + " " + date.toLocaleTimeString() + "]" +
`
Hashes per second: ${data.hashesPerSecond}
Total hashes: ${data.totalHashes}
Accepted hashes: ${data.acceptedHashes}
`);
});
})();
Hello,
I'm trying to run this as part of a headless Debian setup. This requires to run this without any console interfaces or the like.
My "setup" is one bash script that invokes the miner:
If I run the miner from command line it works fine. However, as soon as I try to start it as a service or background process, the miner terminates.
So far, I've tried:
1)
nohup /root/coinhive/miner &
Resulting in2)
Resulting in: Process starts in background, but halts/terminates as soon as I hit disown.
3) Crontab:
@reboot /root/coinhive/miner &
Resulting in: Miner not starting at all.4)
Ctrl + Z
doesn't respond at all.It seems to me that for the miner to work, there has to be some sort of terminal or window active. Please advise.