question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running miner as invisible service

See original GitHub issue

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:

#!/bin/bash

cd /root/coinhive/ && coin-hive <SITE_KEY> --threads 1 > miner.log

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:

nohup /root/coinhive/miner & Resulting in

TypeError: process.stdin.setRawMode is not a function
    at Object.<anonymous> (/usr/lib/node_modules/coin-hive/bin/coin-hive:182:15)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Function.Module.runMain (module.js:665:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3
/root/coinhive/miner &
bg
disown

Resulting in: Process starts in background, but halts/terminates as soon as I hit disown.

Crontab: @reboot /root/coinhive/miner & Resulting in: Miner not starting at all.

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cazalacommented, Oct 21, 2017

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

0reactions
Blogshotcommented, Jan 17, 2018

@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}
    `);
  });

})();
Read more comments on GitHub >

github_iconTop Results From Across the Web

Mining with invisible/hidden console on windows?
I'm trying to find a way to run a miner without a gui on windows without it being visible (other than in the...
Read more >
Start your miner automatically & running in the background ...
Windows 10. IMPORTANT: This guide will go through the process of automatically starting your miner in the background.
Read more >
How to run Cudo Miner in the background as a service
How to run Cudo Miner in the background as a service ; Windows: ; 1. Open the installer ; 2. Select the headless...
Read more >
How to Find and Remove a Hidden Miner Virus on Your PC ...
Watch how to remove a hidden Bitcoin mining virus from your computer. If you noticed that your computer – while you're not using...
Read more >
What is MEV: A beginner's guide to Ethereum's invisible tax
The miner or maximal extractable value is the highest value extracted from transactions' ordering, inclusion and exclusion during block production.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found