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
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:
start module:
pm2 start tars-node-web
pm2 start tars-user-system
stop module
pm2 stop tars-node-web
pm2 stop tars-user-system
restart module
pm2 start tars-node-web
pm2 start tars-user-system
Note that if you find that there is no PM2 command, the node environment traversal does not take effect. You can execute:
centos: source ~/.bashrc
ubunut: source /etc/profile
The environment variable of node is automatically installed when tars is installed. Note that the user is root.
The tars-user-system is responsible for maintaining the permissions of tar web. 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 ;
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 .
If the tars web runs abnormally, for example, the page cannot be opened, you can check it in the following ways:
stop web
pm2 stop tars-node-web
Enter the directory and start the service manually
cd /usr/local/app/web
npm run dev
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:
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
If you are a nodejs developer, you can also participate in the development of the web in the following ways:
tars-node-web & tars-user-system are developed by nodejs + koa.
The directory of tars-user-system is /usr/local/app/web/demo.
The code architecture of the two modules is the same. We will explain it with tar node web: