Pi interface for Siemens Spectrum Power tg (Linux)



Download 0.55 Mb.
Page12/18
Date29.01.2017
Size0.55 Mb.
#11562
1   ...   8   9   10   11   12   13   14   15   ...   18

Interface Stop Script


In the interface directory, there is a standard script that can be used to stop the interface when it is running in the background. This script is called PISIPowerTG_stop. It will look for a running process with the name PISIPowerTG and send it a terminate signal.

When running multiple instances of the interface, the script should be copied and edited so that each copy will only kill the required interface.


Automatic startup and shutdown


To simplify the management of the system, the interface is normally configured so that it will automatically start and stop when the other PI processes are started and stopped. This is done with the $PIHOME/bin/sitestart and $PIHOME/bin/sitestop scripts. The pistart and pistop scripts use these scripts for any site-specific commands and are typically used to start and stop the interfaces.

Note: Before configuring the sitestart and sitestop scripts, ensure that the interfaces are properly configured and have been manually started and stopped without any problems.

To have the interface automatically start when the pistart script is run, append the following to the sitestart script.



if [ -x $PIHOME/interfaces/SIPowerTG/PISIPowerTG.sh ]; then
cd $PIHOME/interfaces/SIPowerTG
$PIHOME/interfaces/SIPowerTG/PISIPowerTG.sh
else
echo "ERROR - PISIPowerTG.sh not found"
fi

It will check to see if the interface files are present and if so, it will start the interface. If the file is not found then the script will output an error message.

To have the interface stopped when the pistop script is run, append the following to the end of the sitestop script.

verify_stopped PISIPowerTG

This calls the function defined in the script to find the PID of the interface, send a terminate signal to the process and wait for up to 5 minutes for the interface to stop.

Sample sitestart and sitestop scripts are included in the install kit and can be copied into the $PIHOME/bin directory.

Automatic startup on a reboot


To have the PI API processes and the interface automatically start on a reboot, startup scripts must be set up in the standard Linux init.d directories. To set up the automatic startup

  1. Change to the root user
    su

  2. Copy the required PIAPI script from the interface directory to /etc/init.d
    cp $PIHOME/interfaces/SIPowerTG/PIAPI /etc/init.d

    The PIAPI script in the interface kit should be used when the PI API and interface processes are to be run by the root user.
    If the PI API and interfaces processes need to be run by a different user (i.e. piadmin), then the PIAPI_nonroot script should be used.

  3. Edit /etc/init.d/PIAPI script to set the PIHOME variable to match the requirements for the system.
    By default, the PIAPI_nonroot script will set the PIUSER variable to use the owner of the $PIHOME/bin/pistart and $PIHOME/bin/pistop files.
    If for some reason, the script needs to use a user other than the owner the PI API files, it can be overridden by manually defining the PIUSER variable to be the required user name in the PIAPI script.

  4. Use chkconfig to add the links and verify the configuration
    /sbin/chkconfig --add PIAPI
    /sbin/chkconfig --list PIAPI
    The PIAPI script should be configured to start at run levels 3, 4 and 5.

  5. Verify the configuration by running the commands
    PIAPI start - start the PI API processes
    PIAPI status - show that status of the PI API processes
    PIAPI stop - stop the PI API processes

  6. Once the commands above as working as expected, reboot the system and checking that the PI API processes start and are owned by the correct user. If there are problems with the PIAPI script during a reboot, check the /var/log/messages file for the error messages. If there are no error messages logged then, then check the $PIHOME/dat/pimesslogfile and $PIHOME/dat/PISIPowerTG.out files.

Terminating Background Processes


Normally, the PISIPowerTG_stop script can be used to stop the interface process. However, if the script is not working, or you wish to stop a process with a different name, use the following instructions.

First, obtain the process id (PID) of the background job. This is done as follows. First execute the command:



ps -ef | grep PISIPowerTG

which will produce output similar to:

powertglocal 2527 1 0 09:24 pts/0 00:00:00 ./PISIPowerTG …

The second column is the pid of the process. That is, 2527 is the PID of the PISIPowerTG interface in the example above.

The process is then stopped by:

kill 2527

The kill command sends the SIGTERM signal to the interface, causing the exit handler to be invoked.

Unless it cannot be avoided, do NOT stop the interface with kill –9 pid. The option -9 causes the SIGKILL signal to be sent to the interface. The exit handler cannot catch this signal. SIGKILL will immediately terminate the process, but the process will not be able to shut down in an orderly manner.

Anomalous Background Job Termination


On some platforms, processes that are started in the background will be terminated if one types “control-c” in the same window that the job was started in. This is because the shell is passing the terminate signal to the background processes started by that instance of the shell.

A way of insuring that background processes are not accidentally terminated is to use a shell that does not propagate the terminate signal to background processes. If the ksh, bash or csh shells are used then the Ctrl-C from the foreground will not terminate processes in the background.

If the system does not support any of these shells then close the current window or logout immediately after starting the background tasks, the user will not be able to accidentally terminate the job in this manner.



  1. Download 0.55 Mb.

    Share with your friends:
1   ...   8   9   10   11   12   13   14   15   ...   18




The database is protected by copyright ©ininet.org 2022
send message

    Main page