当前位置:网站首页>Lighthouse locally deployed TCA code analysis tool

Lighthouse locally deployed TCA code analysis tool

2022-06-23 04:34:00 m0re

Project brief introduction

Tencent/CodeAnalysis: Static Code Analysis (github.com)

stay Github Hang around , Found out TCA This project of Tencent cloud , Curious, I went in and had a look

The official document describes this :

Tencent cloud code analysis (Tencent Cloud Code Analysis, abbreviation TCA, R & D code used internally CodeDog) It is a comprehensive code analysis platform , Including the server 、Web End and client components , Support the integration of common code analysis tools in the industry , Its main function is to ensure the code quality under the agile iteration of multi project , And support the team to inherit the code culture .

According to the official documents ,TCA It has the following key functions :

Language support : Support Java/C++/Objective-C/C#/JavaScript/Python/Go/PHP Dozens of languages , Cover common programming languages .

Code checking : Accurately track and manage the code quality defects found through code inspection 、 Code specification 、 Code security vulnerability 、 Invalid code, etc . At present, it has integrated many self-developed 、 Well known open source analysis tools , And adopts a layered separation architecture , It can meet the requirements of the team's rapid self-service management tool .

Code metrics : Support code circle complexity 、 The three dimensions of code repetition rate and code statistics monitor the current code .

DevOps Integrate : The client starts from the command line , It can quickly connect to each DevOps Scheduling system , And pass the standard API Interface with upstream and downstream systems

As a web End code detection tool , The official documentation states that the project can be privatized and deployed , Also support docker, This deployment uses local deployment installation

Installation and deployment :

operating system :CentOS 7.6

The server : Tencent cloud Lighthouse 2C4G6M Guangzhou three districts

Software :ssh and ftp Tools , What I'm using here is xshell and xftp

The deployment environment :

install MySQL5.7

#  install  mysql yum Source 
wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm 
#  install MySQL
yum localinstall mysql57-community-release-el7-11.noarch.rpm
yum install mysql-community-server
#  start-up MySQL
systemctl start mysqld
#  confirm MySQL Normal start 
systemctl status mysqld
#  Look at the build  MySQL root User temporary password :
grep 'temporary password' /var/log/mysqld.log
#  modify root User password :
#  Connect MySQL service 
mysql -uroot -p #  Output the temporary password queried above 
#  modify root User's password ( The following is changed to  [email protected], Here you can adjust it according to your own needs ):
ALTER USER 'root'@'localhost' IDENTIFIED BY '[email protected]';

install Redis

For reference only , Not applicable to formal environment deployment , For formal environments, it is recommended to use professional Redis service ( For example, Tencent cloud Redis product )

# yum  install  redis
yum install redis
#  modify redis password 
vim /etc/redis.conf  
#  find  requirepass foobared#  Copy a line and adjust the password according to your needs , such as  requirepass tca123
#  start-up redis
systemctl start redis
#  see redis Running state 
systemctl status redis
#  visit redis
redis-cli  127.0.0.1:6379> auth tca123 OK #  Authentication passed 

install Python

#  download Python Installation package 
wget https://www.python.org/ftp/python/3.7.12/Python-3.7.12.tgz
#  Install dependent components 
yum -y install wget zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel xz-devel
#  Unzip to /usr/local/src Catalog  $ 
tar zvxf Python-3.7.12.tgz -C /usr/local/src  
cd /usr/local/src/Python-3.7.12 #  Configuration before compilation   
./configure prefix=/usr/local/python3 --enable-shared 
#  Compiling and constructing  
make -j8 #  install Python 
make install #  Clean up the intermediate files of the compiled output  
make clean #  Link building outputs Python Executable to /usr/local/bin Catalog  
ln -s /usr/local/python3/bin/python3 /usr/local/bin/python #  Link building outputs pip3 Executable to /usr/local/bin Catalog  
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip #  Link building outputs Python Dynamic library  
ln -s /usr/local/python3/lib/libpython3.7m.so.1.0 /usr/lib/libpython3.7m.so.1.0 #  Configure dynamic libraries  
ldconfig
#  Domestic cloud servers , It is strongly recommended to change to domestic software source 
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

install Nginx

# yum install ningx
yum install nginx

Application deployment

start-up Server End :

#  Upload the file to the server and unzip ,CentOS Built in unzip
#  Move the source code to data Folder and rename to /tca_open_source
mv CodeAnalysis-main/ /data/
mv /data/CodeAnalysis-main /data/tca_open_source/
#  Get into Server After the service working directory ( Suppose the working directory is /data/tca_open_source/server/, The following paths are relative paths within the working directory )
cd /data/tca_open_source/server/
#  To configure MySQL and Redis service , Initialization data (MySQL Version run version :5.7) perform 
vim ./scripts/config.sh
#  Fill in the database and Redis Information and adjust the configuration information as needed , Default values have been provided for major engineering configurations , The field description allows you to view the document 
# MySQL Of root The password for [email protected],Redis The password for tca123
#  Perform initialization DB、 Install dependencies and run initialization scripts 
./scripts/deploy.sh init
#  Will be installed celery And gunicorn The executable file establishes a soft link to /usr/local/bin Under the path 
ln -s /usr/local/python3/bin/celery /usr/local/bin/celery 
ln -s /usr/local/python3/bin/gunicorn /usr/local/bin/gunicorn 
#  Environment variables take effect 
export PATH=/usr/local/bin:$PATH
#  Start the service execution 
./scripts/deploy.sh start
#  Stop service execution 
./scripts/deploy.sh stop

The status description as shown in the figure appears server End deployment succeeded

start-up web End

# Switch to tca-deploy-source Of web Catalog , Think of it as a working directory ( Suppose the working directory is  
cd /data/tca_open_source/web/tca-deploy-source
#  Execute the initialization command : Set the default environment variables , Install front-end resources , To configure  hosts、nginx  etc. , start-up  nginx  service 
sh init.sh -d

Web End deployment succeeded

原网站

版权声明
本文为[m0re]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/01/202201161142309534.html