PLC Service
From PlcWiki
Line 8: | Line 8: | ||
/usr/local/plc/bin/plc_service_install <service name> | /usr/local/plc/bin/plc_service_install <service name> | ||
- | This command will install and start a new system service. If the program has the same name as the service, is in /usr/local/plc/bin/ directory and doesn't take any command line options, no other configuration is needed. | + | This command will install and start a new system service. If the program has the same name as the service, is in <tt>/usr/local/plc/bin/</tt> directory and doesn't take any command line options, no other configuration is needed. |
- | Also if a file with name /usr/local/plc/etc/<service name>_<WPID>.cfg or /usr/local/plc/etc/<service name>.cfg exists, it is passed as a parameter to the program by default and no configuration is needed, supposed this is the only option that the program needs. | + | |
+ | Also if a file with name <tt>/usr/local/plc/etc/<service name>_<WPID>.cfg</tt> or <tt>/usr/local/plc/etc/<service name>.cfg</tt> exists, it is passed as a parameter to the program by default and no configuration is needed, supposed this is the only option that the program needs. | ||
=Service uninstallation= | =Service uninstallation= | ||
Line 27: | Line 28: | ||
Service configuration file has to be named like this (sorted in the order of precedence): | Service configuration file has to be named like this (sorted in the order of precedence): | ||
- | # /usr/local/plc/etc/service/<name>.cfg | + | # <tt>/usr/local/plc/etc/service/<name>.cfg</tt> |
- | # /usr/local/plc/etc/service/<name> | + | # <tt>/usr/local/plc/etc/service/<name></tt> |
- | # /usr/local/plc/etc/<name>.service.cfg | + | # <tt>/usr/local/plc/etc/<name>.service.cfg</tt> |
- | # /usr/local/plc/etc/<name> | + | # <tt>/usr/local/plc/etc/<name></tt> |
=Commented configuration file example= | =Commented configuration file example= |
Revision as of 07:33, 14 October 2010
PLC Service is a unified way of running tasks in the background.
Any script or program can be run as a system service.
Contents |
Service installation
/usr/local/plc/bin/plc_service_install <service name>
This command will install and start a new system service. If the program has the same name as the service, is in /usr/local/plc/bin/ directory and doesn't take any command line options, no other configuration is needed.
Also if a file with name /usr/local/plc/etc/<service name>_<WPID>.cfg or /usr/local/plc/etc/<service name>.cfg exists, it is passed as a parameter to the program by default and no configuration is needed, supposed this is the only option that the program needs.
Service uninstallation
/usr/local/plc/bin/plc_service_uninstall <service name>
This command stops and uninstalls given PLC service.
Service list
/usr/local/plc/bin/plc_service_list [-s]
List all installed PLC services. -s option also shows their status.
Service configuration
Service configuration file has to be named like this (sorted in the order of precedence):
- /usr/local/plc/etc/service/<name>.cfg
- /usr/local/plc/etc/service/<name>
- /usr/local/plc/etc/<name>.service.cfg
- /usr/local/plc/etc/<name>
Commented configuration file example
# Not necessary if the program name is the same as the service name PROGRAM="/usr/local/plc/bin/blah" # Start again if the process gets killed by accident or crashes. # Set to "yes" by default. KEEPRUNNING=yes # Command line arguments OPTIONS="-v" # Default stdout log file is named /usr/local/plc/log/<name>.service.log" #LOG=/tmp/logfile.log # Default error log file is named /usr/local/plc/log/<name>.service.err.log" #ERRORLOG=/tmp/errlogfile.log # If set, standard output and standard error output are redirected to the same file ( $LOG ). # Set to "yes" by default. #COMMONLOG=no # Any other variables set here will be accessible from the program RUNFASTER=yes DONTCRASH=yes