RE: RE: Essential Guide to Becoming a Steem Witness
You are viewing a single comment's thread from:

RE: Essential Guide to Becoming a Steem Witness

RE: Essential Guide to Becoming a Steem Witness

Using Ubuntu's Upstart to Make Steem a Service

This post is an addendum to the essentials document and describes how to use Ubuntu's upstart to make Steem a startup service with minimal fail protection (to restart the service if the process dies or server reboots).

Modifying and Installing The Steem Upstart Script

The full script is provided at the bottom of this post. Save it as "steem.conf". The service will be called "steem".

You will want to change several parts of this script to fit your setup:

  • Change the "author" and email.
  • Change the "chdir" line to the path of your Steem working directory (one directory higher than witness_data_dir).
  • Change the "exec" line to point to your steemd daemon.

Once you have edited the script, copy it as sudoer to the /etc/init directory:

sudo cp steem.conf /etc/init/steem.conf

Starting the Steem Service

The easiest way to start the Steem service (and test your config at the same time) is to simply reboot your computer. It is recommended to go ahead and reboot because you will want to test that the steem service starts on reboot anyway. I reboot like this:

sudo reboot

If you don't wish to reboot, you can do the simple command (ensuring first that all other instances of steemd are stopped)

sudo start steem

You can verify that the steem service is running with this command:

ps aux | grep steemd

Which will give something similar to the following output:

ima@ubuntu:~$ ps aux | grep steemd
root       966  0.5  3.5 607992 141480 ?       Ssl  09:07   4:06 /root/steemd --rpc-endpoint

Testing the Service

The first test should have been when you rebooted to start the steem service.

Let's assume that you your ps output included the line:

root       966  0.5  3.5 607992 141480 ?       Ssl  09:07   4:06 /root/steemd --rpc-endpoint

This means that steemd is running as process 966. Let's kill that process and see if the steem service bounces back. The way to kill process 966 is with this command:

sudo kill 966

Here is my output of the full process. Yours should look similar.

ima@ubuntu:~$ ps aux | grep steemd
root       966  0.5  3.5 607992 141736 ?       Ssl  09:07   4:08 /root/steemd --rpc-endpoint
ima       3130  0.0  0.0  11744   924 pts/1    S+   21:22   0:00 grep --color=auto steemd
ima@ubuntu:~$ sudo kill 966
ima@ubuntu:~$ ps aux | grep steemd
root      3132  0.0  0.3 137676 12268 ?        Rsl  21:22   0:00 /root/steemd --rpc-endpoint
ima       3136  0.0  0.0  11740   932 pts/1    S+   21:22   0:00 grep --color=auto steemd

It looks like success. The steemd daemon respawned as process 3132 within seconds of the kill. You may be wondering what the "ima" lines are in the ps output. Those are simply the grep processes I used to filter the full ps output.

Steem Service Upstart Script

# steemservice - steem daemon service for witness
    
description "Steem"
author "Ima Witness <ima@imawitness.net>"

# Stanzas
#
# Stanzas control when and how a process is started and stopped
# See a list of stanzas here: http://upstart.ubuntu.com/wiki/Stanzas

# When to start the service
start on runlevel [2345]

# When to stop the service
stop on runlevel [016]

# Automatically restart process if crashed
respawn

# Essentially lets upstart know the process will detach itself to the background
# This option does not seem to be of great importance, so it does not need to be set.
#expect fork

# Specify working directory
chdir /path/to/steem/working/dir

# Specify the process/command to start, e.g.
exec /path/to/steem/daemon/steemd --rpc-endpoint 2>>debug.log 1>error.log
H2
H3
H4
3 columns
2 columns
1 column
5 Comments