4

I installed ethereumjs-testrpc via npm and I start it in my terminal by running testrpc. CTRL+C does not stop it and I'm forced to suspend it with CTRL+z and then kill -9 ... it every time. Is this behavior by design? Is there a way to stop it like any other process?

Fedora 26 user here.

2
  • Fedora sucks, use Ubuntu
    – Nulik
    Commented Oct 15, 2017 at 13:20
  • @Nulik easy there. same issue happens in ubuntu. Commented Oct 16, 2017 at 16:19

5 Answers 5

3

I would suggest to create a systemctl service. Please find below the procedure (root permission required):

1. Create a service file

$ vi /etc/systemd/system/testrpc.service

2. Add the content

[Unit]
Description = Start testrpc
After = network.target
[Service]
ExecStart = /usr/lib/node_modules/ethereumjs-testrpc/bin/testrpc
[Install]
WantedBy = multi-user.target

You might have to change the path of the testrpc executable

3. Reload the daemon services and enable testrpc service

$ systemctl daemon-reload
$ systemctl enable testrpc

That's done

Usage

Start the service

systemctl start testrpc

Stop the service

systemctl stop testrpc

Restart the service

systemctl restart testrpc

Check the status of the service

systemctl status testrpc

● testrpc.service - Start testrpc
   Loaded: loaded (/etc/systemd/system/testrpc.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2017-10-15 11:23:38 UTC; 2s ago
 Main PID: 29880 (node)
    Tasks: 6
   Memory: 817.8M
      CPU: 1.826s
   CGroup: /system.slice/testrpc.service
           └─29880 node /usr/lib/node_modules/ethereumjs-testrpc/bin/testrpc
Oct 15 11:23:40 instance-1 testrpc[29880]: (5) 59eeef2c9e108c23f24b385d841b8615f14362f1e1c8b413c5caf563c48f70bb
Oct 15 11:23:40 instance-1 testrpc[29880]: (6) 529d71f653a52a26d24263f9967308207a5b6e59111797c0fe423f1909926165
Oct 15 11:23:40 instance-1 testrpc[29880]: (7) f52acfc25e53a52bf493909f58b222dda288c06a01e6922fdc7e38dabb0b7487
Oct 15 11:23:40 instance-1 testrpc[29880]: (8) 6cdebc1efe3d82f30e6242a595cf80eec813252fc25710151e08c1c7b9e26609
Oct 15 11:23:40 instance-1 testrpc[29880]: (9) 4da9f0d0af082f7ad649f082136f0244774d597b34b8d3b492951decb23a8335
Oct 15 11:23:40 instance-1 testrpc[29880]: HD Wallet
Oct 15 11:23:40 instance-1 testrpc[29880]: ==================
Oct 15 11:23:40 instance-1 testrpc[29880]: Mnemonic:      obscure enact cushion throw rabbit flame chest suggest stick library dice three
Oct 15 11:23:40 instance-1 testrpc[29880]: Base HD Path:  m/44'/60'/0'/0/{account_index}
Oct 15 11:23:40 instance-1 testrpc[29880]: Listening on localhost:8545

View testrpc's output

sudo journalctl -u testrpc

If you are curious, more info about Linux systemd here.

2
  • This means that you need to run watch systemctl status testrpc to see what testrpc is doing.
    – Tom Hale
    Commented Oct 23, 2017 at 9:27
  • You can also find the log into "/var/log/syslog" Commented Oct 23, 2017 at 10:32
1

The Ctrl-C doesn't work because this interrupt sequence was disabled for the process with termios library.

To terminate the process use:

kill -TERM [PID]

To pause it, use:

kill -STOP [PID] to pause
kill -CONT [PID] to continue

man 7 signal for more info

0
1

alternatively use

fuser -k -n tcp 8545

8545 is the default port used by testrpc.

1

Using bash:

Press Ctrl-Z, then type:

kill %1
0

Find process id using this command

ps -ef | grep testrpc

501 28308 27835   0 12:13PM ttys001    0:21.56 node /usr/local/bin/testrpc

Then kill this process,

kill -9 28308

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.