Run bitcore-node as a service in the background in Ubuntu 16.04

963 views Asked by At

I successfully installed bitcore and able to run with the bitcore-node start. But I want to run it as service in the background.

Installation Step of Bitcore-node.

curl -sL https://deb.nodesource.com/setup_4.x | sudo bash -
sudo apt-get install nodejs
sudo apt-get install python
sudo apt-get install libzmq3-dev build-essential
npm install -g bitcore-node (https://github.com/bitpay/bitcore-node)

On Running bitcore-node startits working perfectly

I created a service in the /etc/systemd/system

[Unit]
Description=bitcored.service
After=network.target

[Service]
Type=simple
User=ubuntu
Environment="PATH=$PATH:/home/ubuntu/usr/bin"
ExecStart=/root/bin/node /usr/lib/node_modules/bitcore-node/bin/bitcore-node
ExecReload=/bin/kill -2 $MAINPID
KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target

On Executing the command sudo service bitcore status , I am getting following Error.

enter image description here

Any help would be appreciated.

1

There are 1 answers

0
GiorgosK On

I used pm2

# install pm2
npm install pm2 -g

# go into your project and start it with pm2
cd mynode
pm2 start bitcore -- start

# check the logs that all runs smoothly
pm2 logs

# if everything runs fine 
# can setup the script to run on boot/reboot
pm2 startup
pm2 save 

More info