Search code examples
volttron

Volttron init daemon


Apparently my initial question was to vague or was interpreted as a bad question.

I'll try again.

There is a file called volttron located at volttron/scripts/admin/ the contents indicate it is / was for a Volttron daemon to start from init. I notice that it refers to paths outside of the venv (/var/lib/volttron) Why is this file there? Are there plans to revise it? Have people modified this file to achieve start from init? Is there documentation in regards to this subject?

Auto initialization is an extremely important feature for any program that provides a service on a computer system.

I have provided a snippet of the code.

#! /bin/sh
### BEGIN INIT INFO
# Provides:          volttron
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Should-Start:      $network $named
# Should-Start:      $network $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: VOLTTRON (TM) Daemon
# Description:       VOLTTRON (TM) agent execution platform.
### END INIT INFO

# Author: Brandon Carpenter <[email protected]>

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="VOLTTRON (TM) agent execution platform"
NAME=volttron
USER=volttron
VLHOME=/var/lib/volttron
DAEMON_ARGS="-v -l $VLHOME/volttron.log"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

Solution

  • This script (scripts/admin/volttron) was setup assuming you had installed VOLTTRON in var/lib. To use it for your environment, edit VLHOME to where you installed it. For example: /home/volttronuser/git/volttron

    Make the script executable: chmod +x scripts/admin/volttron, then copy it over to /etc/init.d/

    To make it autostart with the OS:

    sudo update-rc.d volttron defaults

    To start and stop it manually:

    sudo service volttron start
    sudo service volttron stop
    

    See the status with:

    sudo service volttron status
    

    If this is going to be used in a deployed situation, it's recommended that you edit the script to use a rotating log configuration (or using http://www.linuxcommand.org/man_pages/logrotate8.html). Edit the arguments in the script to use the -L option when starting VOLTTRON. This will use the rotatinglog configuration.

    DAEMON_ARGS="-v -L $VLHOME/examples/rotatinglog.py"

    You will also need to edit examples/rotatinglog.py to change the location of the log file. Edit "filename" to point to a location your user has permission to write to.

       'handlers': {
            'rotating': {
                'class': 'logging.handlers.TimedRotatingFileHandler',
                'level': 'DEBUG',
                'formatter': 'agent',
                'filename': '/home/myuser/git/volttron/volttron.log',
    

    Note: The cgroups portion of the script supports a VOLTTRON plugin for resource management and isn't needed without that. This is why it's commented out in the start method of the script.