Skip to the content.

Directory

1 Intro

The main functions of tars-web are as follows:

Tars-web installation usually follows the one click installation script or is automatically installed in the docker container. For the source code installation, please refer to tars source code installation

2 Module description

tars web < v2.4.7

Tar web consists of two modules (services implemented by nodejs, implemented by koa framework):

After the system is installed, it is managed by PM2. You can view:

pm2 list

Common commands:

tars web >= v2.4.7

Tar web services implemented by nodejs, implemented by koa framework, bind by default : 0.0.0.0:3000

After the system is installed, it is managed by PM2. You can view:

pm2 list

Common commands:

Other

Note that if you find that there is no PM2 command, the node environment traversal does not take effect. You can execute:

source /etc/profile

The environment variable of node is automatically installed when tars is installed. Note that the user is root.

3 Permission specification

There are three types of user permissions:

The granularity of permissions can be applied to application or service level

For example, if you want to give the operation and maintenance user test, the app is test, and the service is helloserver permission:

If you want to users(test) own all service permissions of app(Test) , mark it as: Test

In the web management platform, you can click specific services -> Click permission management - > enter the user name in the input box of operation and maintenance, development, and multiple users are separated by ;

4 Module call

tars web < v2.4.7

Tars-node-web & Tars-user-system is deployed on the same machine by default, and they are all bound with 0.0.0.0 (that is, 127.0.0.1)

Tars-node-web accesses tars-user-system through localhost (127.0.0.1). If 127.0.0.1 is not bound, it has no permission. At this time, you need to modify the configuration of tars-user-system module (demo/config/loginConf.js), modify ignoreips, and open the white list.

Normally, you can access it through the machine’s Internet IP, for example: http://xxx.xxx.xxx.xxx:3000 web management platform.

If nginx proxy is hung in front of Web & demo, and the reverse proxy is accessed to different ports (a 3000, a 3001), different domain names need to be set to access. The login state of Web & demo is passed through cookies, so it needs to be deployed under the same root domain name.

For example, the domain name of the web’s nginx entry is http://user.tars.com, and the domain name of demo’s nginx is http://auth.tars.com (note that the root domain name is tars.com), so you need to set the environment variable on the web server:

export USER_CENTER_HOST=http://auth.tars.com
export COOKIE_DOMAIN=.tars.com

Pay attention: COOKIE_DOMAIN has .

tars web >= v2.4.7

Tars-node-web are all bound with 0.0.0.0 (that is, 127.0.0.1)

Normally, you can access it through the machine’s Internet IP, for example: http://xxx.xxx.xxx.xxx:3000 web management platform.

5 Inspection problem

tars web < v2.4.7

If the tars web runs abnormally, for example, the page cannot be opened, you can check it in the following ways:

NPM run dev will output the error on the screen. If it is modified according to the error judgment, Ctrl + C will exit NPM run dev.

After the bug is solved, restart the service with PM2:

pm2 start tars-node-web
pm2 start tars-user-system

Two important web logs:

tars web >= v2.4.7

If the tars web runs abnormally, for example, the page cannot be opened, you can check it in the following ways:

NPM run dev will output the error on the screen. If it is modified according to the error judgment, Ctrl + C will exit NPM run dev.

After the bug is solved, restart the service with PM2:

pm2 start tars-node-web

The important web logs:

6 Token Manage

The user module of Web provides the function of token management, that is, you can create token, and call and obtain relevant data through web API, See

7 Password Forget

If the password of admin is forgotten, Now, it can only be solved by resetting the fields of related tables in the database at present:

When you log in to the web, you will be prompted to set the admin password.

8 Web development

If you are a nodejs developer, you can also participate in the development of the web in the following ways:

tars web developed by nodejs + koa.

The code architecture of the two modules is the same. We will explain it with tar node web: