Environmental variables issues in the CentOS service

Source: Internet
Author: User

Problem Description :

in the previous test, Intel Media Server Studio made a hard-coding and put the application into a service script in the/etc/init.d/directory. However, the test found that the effect of using service and/etc/init.d/started differently. When using service startup, the hard-knitting is not working properly and the printing information obtained is:[H264_qsv @ 0x27fa960] Warning:not compiled with thread support, using thread emulation LIBVA info:va-api version 0.35.0 LIBVA info:va_getdrivername () returns 0 LIBVA info:trying to open/usr/lib64/dri/i965_drv_video.so LIBVA info:va_opendriver () returns-1
When booting through/etc/init.d/, it can be hard-coded, and the printing information obtained is:H264_QSV @ 0x384a960] Warning:not compiled with thread support, using thread emulation LIBVA info:va-api version 0.35.0 LIBVA info:va_getdrivername () returns 0 LIBVA Info:user requested driver ' IHD ' LIBVA info:trying to open/opt/intel/mediasdk/lib64/ihd_drv_video.so LIBVA info:found init function __vadriverinit_0_32 LIBVA info:va_opendriver () returns 0 [H264_qsv @ 0x384a960] ZX Debug:ff_qsv_enc_init OK.
Confirm that the program is started with one, so it is doubtful that the service and direct/etc/init.d/execution scripts are different. Troubleshooting:After the investigation, determine the environment variables.
The following environment variables are required for a hard-coding program:"Libva_drivers_path=/opt/intel/mediasdk/lib64",
"LIBVA_DRIVER_NAME=IHD",
"MFX_HOME=/OPT/INTEL/MEDIASDK"

It has been confirmed that the current environment has these environment variables. (found in/etc/profile.d/directory with intel-mediasdk-devel.sh and intel-mediasdk.sh two scripts set environment variables) To troubleshoot the test content: use env on a normal terminal: [Root@localhostetc]# Env
xdg_session_id=261
Hostname=localhost.localdomain
libva_drivers_path=/opt/intel/mediasdk/lib64
selinux_role_requested=
Term=linux
Shell=/bin/bash
histsize=1000
ssh_client=10.33.3.8 49717
selinux_use_current_range=
LIBVA_DRIVER_NAME=IHD
OLDPWD=/ETC/PROFILE.D
SSH_TTY=/DEV/PTS/6
User=root
ls_colors=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05 ; 37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*. arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*. t7z=01;31:*.zip=01;31:*.z=01;31:*. Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31 :*. tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:* . alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*. gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*. tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:* . m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01; 35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:* . anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*. MP3=01;36:*.MPC=01;36:*.OGG=01;36:*.RA=01;36:*.WAV=01;36:*.AXA=01;36:*.OGA=01;36:*.SPX=01;36:*.XSPF=01;36:
ssh_auth_sock=/tmp/ssh-4wzhtoatll/agent.3745
Mail=/var/spool/mail/root
Path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
pwd=/etc
Lang=en_us. UTF-8
MFX_HOME=/OPT/INTEL/MEDIASDK
selinux_level_requested=
histcontrol=ignoredups
shlvl=1
Home=/root
Logname=root
ssh_connection=10.33.3.8 49717 10.33.2.197
lessopen=| | /usr/bin/lesspipe.sh%s
xdg_runtime_dir=/run/user/0
_=/usr/bin/env
[Root@localhostetc]#

write a simple service script,

#!/bin/sh
#export libva_drivers_path=/opt/intel/mediasdk/lib64 #export LIBVA_DRIVER_NAME=IHD #export mfx_home=/opt/intel/mediasdk
start () { echo "Start" Env }
Stop () { echo "Stop" Env }
Restart () { Stop Start }
Case "$" in start) Start         ;; stop) Stop         ;; restart) Restart         ;;     *) echo $ "Usage: $ {start|stop|status|restart}" Exit 2 Esac exit $? Test: [[email protected]init.d]# Service Test Stop
Stop
Term=linux
systemctl_skip_redirect=
Path=/sbin:/usr/sbin:/bin:/usr/bin
pwd=/
Shlvl=1
systemctl_ignore_dependencies=
_=/bin/env visible, there is a lack of many environment variables.
To manually add an environment variable: [[email protected]init.d]# Service Test Stop
Stop
libva_drivers_path=/opt/intel/mediasdk/lib64
Term=linux
LIBVA_DRIVER_NAME=IHD
systemctl_skip_redirect=
Path=/sbin:/usr/sbin:/bin:/usr/bin
pwd=/
MFX_HOME=/OPT/INTEL/MEDIASDK
Shlvl=1
systemctl_ignore_dependencies=
_=/bin/env written at the end:

Check the service manual and you can understand some of the service's details: When the service runs the specified services (known as the System V initial script), most of the environment variables are removed, only the Lang and term environment variables are preserved, and the current path is set to/, This means running the service script in a very clean environment that can be predicted. This script is saved in the/ETC/INIT.D directory, and it supports at least the start and stop commands.

so when using the service, be careful when using environment variables.

Environmental variables issues in the CentOS service

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.