blockchain / service-my-wallet-v3

Blockchain Wallet API Service
https://blockchain.info/api/blockchain_wallet_api
GNU Affero General Public License v3.0
910 stars 518 forks source link

Request 'status' and 'stop' service entry points #62

Open nebaughman opened 8 years ago

nebaughman commented 8 years ago

Service v0.17.2, Node v0.12.10

Augment cli.js with status and stop entry points. Status reports whether a service instance is currently running. Stop performs a clean shutdown of a running service instance.

These calls would be useful for integration with typical OS service start/stop scripts (e.g., to start the service on boot and stop cleanly on shutdown). Status is useful in monitoring (e.g., to perform automated restart upon unexpected shutdown).

jtormey commented 8 years ago

Great suggestions, I'll add these to my todo list.

anver commented 8 years ago

For now you can check if the service is running or not using the following command

$ ps ax | grep -v grep | grep 'blockchain'

and to stop the service you need to use kill that's the only way i know for now

Step 1 Get the process number using the above command

Step 2 kill processnumber

That will stop all the blockchain wallet service on the server

The other issue I faced was the service was stopping for some reason and as far as now I didn't find a solution for that, I needed to create a bash script which sends an alert email that the service stopped and it will restart the service again something like this

!/bin/bash

/usr/local/bin/blockchain-wallet-service --start port 3000 mail anvergdr@gmail.com -s "Blockchain wallet service stop - Critical error"

Now I ran this script using nohup ./bcscript &

then I put this as a background job by pressing ctrl + z

If this is what you do then you will not be able to stop the service using the above method, first you need to stop the background job then follow the instructions above which will cleanup the service proper way.