项目场景:
在信创项目中,麒麟操作系统(兆芯)客户端访问web端程序时,PC机器上需要安装读卡器读卡服务(自定义服务)才能读取身份证/卡片信息,并开机自启动。
解决方案:
/usr/local/custom-server目录下结构
libs文件夹(.so文件)
logs文件夹(日志文件)
read-card-service.jar
read-card-service.yml
1.创建自启动服务配置文件
bash
sudo vim /etc/systemd/system/read-card.service
2.添加自启动文件配置
bash
[Unit]
Description=Read Card Service
After=network.target
[Service]
Environment="LD_LIBRARY_PATH=/usr/local/custom-server/libs"
ExecStart=/usr/local/java/jdk1.8.0_361/bin/java -jar /usr/local/custom-server/read-card-service.jar --spring.config.location=/usr/local/custom-server/read-card-service.yml
WorkingDirectory=/usr/local/custom-server
User=root
Group=root
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
3.重新加载systemd配置
bash
sudo systemctl daemon-reload
4.启动服务
bash
sudo systemctl enable read-card.service
sudo systemctl start read-card.service
5.查看服务状态
bash
sudo systemctl status read-card.service
6.添加信任区
bash
sudo chmod 644 /etc/systemd/system/read-card.service
7.重启电脑验证服务是否自启动
注意!!!如果重启弹出阻止应用窗口,则需要在安全中心添加应用保护(推荐)或者关闭所有应用保护(不推荐)。