### Example: Master Node Installation Source: https://tarscloud.github.io/TarsDocs_en/installation/source.html Example command for installing the Tars framework on a master node. Replace placeholders with your specific MySQL details and network interface. ```bash chmod a+x linux-install.sh ./linux-install.sh 192.168.7.153 tars2015 eth0 false false ``` -------------------------------- ### Example: Slave Node Installation Source: https://tarscloud.github.io/TarsDocs_en/installation/source.html Example command for installing the Tars framework on a slave node. Note the 'true' parameter for SLAVE, indicating this is a slave node. ```bash chmod a+x linux-install.sh ./linux-install.sh 192.168.7.153 tars2015 eth0 false true ``` -------------------------------- ### Installation and Basic Usage Source: https://tarscloud.github.io/TarsDocs_en/dev/tars.js/tars-winston-tars.html Instructions on how to install the @tars/winston-tars package and a basic example of how to integrate it with Winston. ```APIDOC ## Installation `npm install @tars/winston-tars` ## Basic Usage ```javascript var winston = require('winston'); // Requiring `@tars/winston-tars` will expose // transports // `winston.transport.TarsRotate` // `winston.transport.TarsDate` // config // `winston.config.tars.levels` // `winston.config.tars.colors` require('@tars/winston-tars'); var logger = new (winston.Logger) ({ transports: [ new (winston.transports.Console) ({}) ] }); ``` ``` -------------------------------- ### Service Template Config File Path Example Source: https://tarscloud.github.io/TarsDocs_en/question/Install_faq-en.html Example of the directory containing template configuration files for a service. These files are essential for service setup. ```bash /usr/local/app/tars/tarsnode/data/Test.HelloServer/conf/ ``` -------------------------------- ### MySQL Configuration Example (my.cnf) Source: https://tarscloud.github.io/TarsDocs_en/installation/mysql.html An example configuration file for MySQL. Adjust parameters like buffer pool size, logging, and bind address according to your system's resources and network setup. ```ini # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. log_bin # These are commonly set, remove the # and set as required. basedir = /usr/local/mysql datadir = /usr/local/mysql/data # port = ..... # server_id = ..... socket = /tmp/mysql.sock bind-address=${your machine ip} # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. join_buffer_size = 128M sort_buffer_size = 2M read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES ``` -------------------------------- ### Create Installation Directories Source: https://tarscloud.github.io/TarsDocs_en/installation/source.html Prepare the system directories for Tars installation. ```bash cd /usr/local mkdir tars mkdir app ``` -------------------------------- ### Install TarsGo and Protobuf Dependencies Source: https://tarscloud.github.io/TarsDocs_en/dev/tarsgo/pb2tarsgo.html Install the TarsGo framework and the necessary Go protobuf packages. Ensure the protoc compiler is installed separately. ```bash go get github.com/TarsCloud/TarsGo/tars go get github.com/golang/protobuf/{proto,protoc-gen-go} install protoc ``` -------------------------------- ### Install Docker on CentOS Source: https://tarscloud.github.io/TarsDocs_en/installation/docker-install.html Executes the installation of Docker CE and configures it to start on boot. ```bash sudo su yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo yum install -y docker-ce systemctl start docker systemctl enable docker ``` -------------------------------- ### Manually Start Tars Web Services Source: https://tarscloud.github.io/TarsDocs_en/installation/source-windows.html Navigate to the Tars installation directory and use 'npm run start' to manually start the web and demo services. This is useful for troubleshooting if services fail to start via PM2. ```bash cd c:\tars-install\web\demo; npm run start cd c:\tars-install\web; npm run start ``` ```bash cd c:\tars-install\web; npm run start ``` -------------------------------- ### Test Docker installation Source: https://tarscloud.github.io/TarsDocs_en/dev/tarsjava/tars-quick-start.html Verifies that Docker has been installed successfully by running the 'hello-world' container. ```bash docker run hello-world ``` -------------------------------- ### Install and run TARS via Docker Source: https://tarscloud.github.io/TarsDocs_en/dev/tarsphp/Environment/docker.html Initializes local data directories and starts the MySQL and TARS containers with required environment variables. ```bash mkdir -p /data/tars/mysql_data mkdir -p /data/tars/tars_data docker run --name mysql -e MYSQL_ROOT_PASSWORD=(your DB password) -d -p 3306:3306 -v /data/tars/mysql_data:/var/lib/mysql mysql:5.6 --innodb_use_native_aio=0 docker run -d -it --name tars --link mysql --env MOUNT_DATA=false --env DBIP=mysql --env DBPort=3306 --env DBUser=root --env DBPassword=(DB password) -p 3000:3000 -v /data/tars/tars_data:/data tarscloud/tars:php ``` -------------------------------- ### Prepare MySQL Installation Directory Source: https://tarscloud.github.io/TarsDocs_en/installation/mysql.html Sets up the directory structure and ownership for MySQL installation. This involves creating a directory and a symbolic link. ```bash cd /usr/local mkdir mysql-5.6.26 chown ${owner}:${owner} ./mysql-5.6.26 ln -s /usr/local/mysql-5.6.26 /usr/local/mysql ``` -------------------------------- ### Start RPC Server Source: https://tarscloud.github.io/TarsDocs_en/dev/tars.js/tars-rpc.html Execute the main server script to start the RPC server. Ensure you are in the server's directory. ```bash node main.js ``` -------------------------------- ### Start Services from Configuration File Source: https://tarscloud.github.io/TarsDocs_en/dev/tars.js/tars-rpc.html Iterates through servants defined in a configuration file to start multiple services. ```javascript // STEP01 introduces key modules var Tars = require ("@ tars / rpc"); var TRom = require ("./ NodeJsCommImp.js"); Tars.server.getServant ("./ TRom.NodeJsTestServer.config.conf"). ForEach (function (config) { var svr, map; map = { 'TRom.NodeJsTestServer.NodeJsCommObj': TRom.NodeJsCommImp }; svr = Tars.server.createServer (map [config.servant]); svr.start (config); }); ``` -------------------------------- ### Start and Enable MySQL Service Source: https://tarscloud.github.io/TarsDocs_en/installation/mysql.html Starts the MySQL service and configures it to start automatically on system boot. Ensure the service script is correctly placed and executable. ```bash service mysql start chkconfig mysql on ``` -------------------------------- ### Install tars2go Tool Source: https://tarscloud.github.io/TarsDocs_en/env/tarsgo.html Install the tars2go binary from the downloaded TarsGo source directory. ```bash go install $GOPATH/src/github.com/TarsCloud/TarsGo/tars/tools/tars2go ``` -------------------------------- ### Install TarsFramework Source: https://tarscloud.github.io/TarsDocs_en/installation/source.html Execute the installation script after compilation. ```bash cd build make install ``` -------------------------------- ### Navigate to Tars Web Demo Directory and Start Source: https://tarscloud.github.io/TarsDocs_en/installation/source.html Use this command to navigate to the demo directory of Tars Web and start the service. This is useful for locating and resolving startup issues. ```bash cd /usr/local/app/web/demo; npm run start ``` -------------------------------- ### Service Log File Path Example Source: https://tarscloud.github.io/TarsDocs_en/question/Install_faq-en.html Example of the directory structure for service log files. Ensure logs are checked here if issues arise. ```bash /usr/local/app/tars/app_log/Test/HelloServer/ ``` -------------------------------- ### Example Adapter Configuration XML Source: https://tarscloud.github.io/TarsDocs_en/dev/tarsgo Shows an example of adapter configuration in XML, defining network endpoints, connection limits, and protocol details for a specific service object. ```xml #each adapter configuration #allow Ip for white list. allow # ip and port to listen on endpoint=tcp -h 10.120.129.226 -p 20001 -t 60000 #handlegroup handlegroup=TestApp.HelloServer.HelloObjAdapter #max connection maxconns=200000 #portocol, only tars for now. protocol=tars #max capbility in handle queue. queuecap=10000 #timeout in ms for the request in the queue. queuetimeout=60000 #servant servant=TestApp.HelloServer.HelloObj #threads in handle server side implement code. goroutine for golang. threads=5 ``` -------------------------------- ### Navigate to Tars Web Directory and Start Source: https://tarscloud.github.io/TarsDocs_en/installation/source.html Use this command to navigate to the main Tars Web directory and start the service. This is useful for locating and resolving startup issues. ```bash cd /usr/local/app/web; npm run start ``` -------------------------------- ### Install Build Dependencies Source: https://tarscloud.github.io/TarsDocs_en/installation/source.html Commands to install required build tools and libraries on various operating systems. ```bash yum install glibc-devel gcc gcc-c++ bison flex cmake psmisc ncurses-devel zlib-devel ``` ```bash sudo apt-get install build-essential bison flex cmake psmisc libncurses5-dev zlib1g-dev ``` ```bash brew install bison flex cmake ``` -------------------------------- ### Tars Server Configuration Example Source: https://tarscloud.github.io/TarsDocs_en/dev/tarscpp/tars-guide.html An example of the XML-based configuration file structure used to initialize the Tars server environment. ```xml #Ip:port of local node node=tars.tarsnode.ServerObj@tcp -h 10.120.129.226 -p 19386 -t 60000 #Application name app=TestApp #Server name server=HelloServer #Local ip localip=10.120.129.226 #Management port local=tcp -h 127.0.0.1 -p 20001 -t 3000 #The server's executable files, configuration files, and so on basepath=/usr/local/app/tars/tarsnode/data/TestApp.HelloServer/bin/ #Data directory of the server datapath=/usr/local/app/tars/tarsnode/data/TestApp.HelloServer/data/ #Log path ``` -------------------------------- ### Service Executable File Path Example Source: https://tarscloud.github.io/TarsDocs_en/question/Install_faq-en.html Example of the directory where service executable files are located. This path is specific to the application and service name. ```bash /usr/local/app/tars/tarsnode/data/Test.HelloServer/bin/ ``` -------------------------------- ### Server Tars file example Source: https://tarscloud.github.io/TarsDocs_en/dev/tarsjava/tars-reference.html Define your service interface within a module. This example shows a simple 'Hello' interface. ```tars module TestApp { interface Hello { string hello(int no, string name); }; }; ``` -------------------------------- ### Server Startup Command Source: https://tarscloud.github.io/TarsDocs_en/dev/tarscpp/tars-guide.html Execute the server binary with the specified configuration file path. ```bash HelloServer --config=config.conf ``` -------------------------------- ### Start HTTP Benchmark Tool Source: https://tarscloud.github.io/TarsDocs_en/benchmark/http-guide.html Use this command to start the tb tool for benchmarking an HTTP service. It specifies the number of requests, concurrency, server details, and the target URL. ```bash ./tb -n 2 -c 5000 -s 20000 -D 192.168.10.3 -P 80 -p http -i 10 -u "http://192.168.16.1/cgi-bin/proxy?cmd=test&f=json" -F aa.txt ``` -------------------------------- ### Create Server with Manual Configuration Source: https://tarscloud.github.io/TarsDocs_en/dev/tars.js/tars-rpc.html Shows how to create a server instance by explicitly providing endpoint and protocol options. ```javascript // STEP01 introduces key modules var Tars = require ("@ tars / tars"). server; var TRom = require ("./ NodeJsCommImp.js"). TRom; // STEP02 Create an instance of the service // Note that "endpoint" and "protocol" are mandatory options, and the format must be the same as the following example var svr = Tars.createServer (TRom.NodeJsCommImp); svr.start ({ name: "TRom.NodeJsTestServer.AdminObjAdapetr", servant: "TRom.NodeJsTestServer.AdminObj", endpoint: "tcp -h 127.0.0.1 -p 14002 -t 10000", maxconns: 200000, protocol: "tars" }); console.log ("server started."); ``` -------------------------------- ### Deploy sample simpleserver Source: https://tarscloud.github.io/TarsDocs_en/installation/k8s-docker-2.html Applies the Kubernetes configuration for the simpleserver example. ```bash cd examples/simple && kubectl apply -f simpleserver.yaml ``` -------------------------------- ### Manually Start Tars Web Service Source: https://tarscloud.github.io/TarsDocs_en/installation/web.html Navigate to the installation directory and start the service manually to view error output in the console. ```bash cd /usr/local/app/web npm run dev ``` -------------------------------- ### Implement HttpServer Initialization and Main Source: https://tarscloud.github.io/TarsDocs_en/demo/tarscpp/tars_cpp_http_demo.html Implementation of the application initialization, including servant registration and protocol parser assignment. ```cpp #include "HttpServer.h" #include "HttpImp.h" #include "util/tc_network_buffer.h" using namespace std; HttpServer g_app; void HttpServer::initialize() { //initialize application here: //... addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".HttpObj"); addServantProtocol(ServerConfig::Application + "." + ServerConfig::ServerName + ".HttpObj",&TC_NetWorkBuffer::parseHttp); } ///////////////////////////////////////////////////////////////// void HttpServer::destroyApp() { //destroy application here: //... } ///////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { try { g_app.main(argc, argv); g_app.waitForShutdown(); } catch (std::exception& e) { cerr << "std::exception:" << e.what() << std::endl; } catch (...) { cerr << "unknown exception." << std::endl; } return -1; } ///////////////////////////////////////////////////////////////// ``` -------------------------------- ### Start Server Command Source: https://tarscloud.github.io/TarsDocs_en/dev/tars.js/tars-rpc.html Command to execute the server entry file. ```bash node server.js ``` -------------------------------- ### Check CMake Version Source: https://tarscloud.github.io/TarsDocs_en/dev/tarscpp/tars-2.0-update.html Verify the installed version of CMake before starting the build process. ```bash cmake --version ``` -------------------------------- ### Example CMake Configuration Output Source: https://tarscloud.github.io/TarsDocs_en/dev/tarscpp/tars-2.0-update.html Sample output showing the configuration summary for a macOS build. ```text jarodruan-mb:cmake-build-debug jarod$ cmake .. ---------------------------------------------------- CMAKE_BUILD_TYPE: Debug PLATFORM: mac INSTALL_PREFIX: /usr/local/tars/cpp ---------------------------------------------------- TARS_MYSQL: ON TARS_HTTP2: OFF TARS_SSL: OFF TARS_PROTOBUF: OFF ---------------------------------------------------- CMAKE_SYSTEM_NAME: Darwin CMAKE_SYSTEM_PROCESSOR: x86_64 CMAKE_CXX_COMPILER_ID: Clang ABI_STR: sysv BF_STR: macho CPU_STR: x86_64 JUMP_SRC: asm/jump_x86_64_sysv_macho_gas.S MAKE_SRC: asm/make_x86_64_sysv_macho_gas.S CMAKE_C_SIZEOF_DATA_PTR: 8 ---------------------------------------------------- -- Configuring done -- Generating done -- Build files have been written to: /Users/jarod/centos/TarsCpp/cmake-build-debug ``` -------------------------------- ### Start Tars Node Web Service with PM2 Source: https://tarscloud.github.io/TarsDocs_en/installation/source-windows.html If the web page is inaccessible, use 'pm2 start tars-node-web' to ensure the service is running. This command is recommended for formal operation after installation. ```bash pm2 start tars-node-web ``` -------------------------------- ### Implement Server Application Source: https://tarscloud.github.io/TarsDocs_en/dev/tarscpp/tars-guide.html Implementation file for the HelloServer class and the main entry point. ```cpp #include "HelloServer.h" #include "HelloImp.h" using namespace std; HelloServer g_app; ///////////////////////////////////////////////////////////////// void HelloServer::initialize() { //initialize application here: //Adding Servant interface to implement binding between class HelloImp and routing Obj addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".HelloObj"); } ///////////////////////////////////////////////////////////////// void HelloServer::destroyApp() { //destroy application here: //... } ///////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { try { g_app.main(argc, argv); g_app.waitForShutdown(); } catch (std::exception& e) { cerr << "std::exception:" << e.what() << std::endl; } catch (...) { cerr << "unknown exception." << std::endl; } return -1; } //////////////////////////////////////////////////////////////// ``` -------------------------------- ### Quick Release Parameters Source: https://tarscloud.github.io/TarsDocs_en/benchmark/build.html Configuration parameters for the install.sh script. ```text webhost Host or ip:port on the TarsWeb management side token Which can obtain the http://webhost/auth.html#/token through the management side adminsip The IP address of the AdminServer deployment, it must be deployed at a single point. It is recommended to deploy together with tarsregistry.。 nodeip The IP address of the NodeServer deployment, it should be separated from the AdminServer, it is recommended to expand the capacity on the management side. The more machines deployed, the stronger the ability to support parallel benchmark. ``` -------------------------------- ### Configure node-agent to run as a specific user Source: https://tarscloud.github.io/TarsDocs_en/dev/tars.js/tars-node-agent.html Example of starting the node-agent as a specific user ('nobody'). This can be configured via command line, package.json, or TARS configuration file. ```bash node-agent app.js –run-as-user = nobody ``` ```json { "nodeAgent" : { "runAsUser" : "nobody" } } ``` ```ini run-as-user = nobody ``` -------------------------------- ### Tars List Operation Example Source: https://tarscloud.github.io/TarsDocs_en/dev/tars.js/tars-stream.html Demonstrates adding elements, getting length, accessing elements by index, and iterating through a Tars List. Also shows conversion to and from objects for lists of custom types. ```javascript var Tars = require ("@tars/stream"); var ve = new Tars.List (Tars.String); // Add elements to the array ve.push ("TENCENT-MIG"); ve.push ("TENCENT-SNG"); ve.push ("TENCENT-IEG"); ve.push ("TENCENT-TEG"); // Get the length of the array console.log ("Length:", ve.length); // Get the element at the specified position console.log ("Array [1]:", ve.at (1)); // Iterate method 1: ve.forEach (function (value, index, oArray) { console.log ("Array [" + index + "]:", value); }); // Traverse method 2: for (var index = 0, len = ve.length; index > v); int set(vector> v); }; ``` -------------------------------- ### Start Tars Server Source: https://tarscloud.github.io/TarsDocs_en/dev/tarsgo Execute the server binary with a specified configuration file. ```bash ./HelloServer --config=config.conf ``` -------------------------------- ### Install tars-extension Source: https://tarscloud.github.io/TarsDocs_en/dev/tarsphp/Framework/tars-extension.html Standard procedure for installing a PHP extension. Ensure to modify php.ini to load the .so file and verify installation with `php -m`. ```bash phpize ./configure make make test make install ``` -------------------------------- ### Install Node Dependencies for Tars-web and Demo Source: https://tarscloud.github.io/TarsDocs_en/installation/expand.html Run these npm install commands within the respective directories to install the necessary dependencies for Tars-web and its demo environment. ```bash cd web; npm install; cd demo; npm install ``` -------------------------------- ### Install @tars/winston-tars Source: https://tarscloud.github.io/TarsDocs_en/dev/tars.js/tars-winston-tars.html Install the @tars/winston-tars package using npm. ```bash npm install @tars/winston-tars ``` -------------------------------- ### Install @tars/utils Source: https://tarscloud.github.io/TarsDocs_en/dev/tars.js/tars-utils.html Install the @tars/utils package using npm. ```bash $ npm install @tars/utils ``` -------------------------------- ### Install Tars Slave Node Source: https://tarscloud.github.io/TarsDocs_en/installation/source-windows.html Execute this command on the slave node to install the Tars framework. Note the 'true' parameter for SLAVE, indicating it's a slave installation. ```bash busybox.exe sh ./windows-install.sh 192.168.7.153 tars2015 192.168.7.152 false true root 3306 ``` -------------------------------- ### Service Entry Point Implementation Source: https://tarscloud.github.io/TarsDocs_en/hello-world/tars.js.html JavaScript code to iterate through servant configurations and initialize servers based on the protocol type. ```javascript const Tars = require("@tars/rpc"); Tars.server.getServant(process.env.TARS_CONFIG).forEach(function (config){ if(config.protocol === "tars"){ //TODO implement tars rpc server start code } else { //TODO implement http server start code } }); ``` -------------------------------- ### Modify Installation Paths Source: https://tarscloud.github.io/TarsDocs_en/installation/source.html Files to update if installing to a non-default directory. ```text **modify tarscpp/cmake/Common.cmake** **modify TARS_PATH in tarscpp/servant/makefile/makefile.tars** **modify TARS_PATH in tarscpp/servant/makefile/tars-tools.cmake** **modify DEMO_PATH in tarscpp/servant/script/create_tars_server.sh** ``` -------------------------------- ### Node.js HTTP Server Implementations Source: https://tarscloud.github.io/TarsDocs_en/hello-world/tars.js.html Examples of setting up HTTP servers using native Node.js and Koa, utilizing environment variables for IP and port. ```javascript const http = require('http'); const hostname = process.env.IP || '127.0.0.1'; const port = process.env.PORT || 3000; const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello World\n'); }); server.listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); }); ``` ```javascript const Koa = require('koa'); const app = new Koa(); const hostname = process.env.IP || '127.0.0.1'; const port = process.env.PORT || 3000; app.use(async ctx => { ctx.body = 'Hello World'; }); app.listen(hostname, port); ``` -------------------------------- ### TARS Extension Installation Source: https://tarscloud.github.io/TarsDocs_en/dev/tarsphp/Framework/tars-extension.html Instructions for installing the tars-extension on a PHP environment. ```APIDOC ## TARS Extension Installation ### Description To install the `tars-extension`, navigate to the extension directory and execute the following commands: ### Commands 1. `phpize` 2. `./configure` 3. `make` 4. `make test` 5. `make install` After installation, modify your `php.ini` file to load the `.so` file. Verify the installation using the `php -m` command. ``` -------------------------------- ### Start Tarsnode Service Source: https://tarscloud.github.io/TarsDocs_en/installation/expand.html Execute this script to start the tarsnode service after configuration. ```bash /usr/local/app/tars/tarsnode/util/start.sh ``` -------------------------------- ### Install Docker CE Source: https://tarscloud.github.io/TarsDocs_en/dev/tarsjava/tars-quick-start.html Installs the Docker Community Edition on your Ubuntu system. ```bash sudo apt-get install docker-ce ``` -------------------------------- ### Initialize Service with Configuration File Source: https://tarscloud.github.io/TarsDocs_en/dev/tars.js/tars-rpc.html Demonstrates initializing a Tars service using a specific configuration file path. ```javascript // STEP01 introduces key modules var Tars = require ("@ tars / rpc"); var TRom = require ("./ NodeJsCommImp.js"); // STEP02 Create an instance of the service // Note the configuration here. In a formal environment, use process.env.TARS_CONFIG to indicate the path of the configuration file // That is: svr.initialize (process.env.TARS_CONFIG, function (server) {...}); var svr = new Tars.server (); svr.initialize ("./ TRom.NodeJsTestServer.config.conf", function (server) { server.addServant (TRom.NodeJsCommImp, server.Application + "." + server.ServerName + ".NodeJsCommObj"); }); // STEP03 After initializing the service in the previous step, start the service svr.start (); ``` -------------------------------- ### Start Tars Web Manually Source: https://tarscloud.github.io/TarsDocs_en/installation/source-windows.html If Tars Web does not start automatically, you can manually start it by navigating to the web directory and running the production script. This is particularly relevant if running within a Docker environment. ```bash cd /usr/local/app/web; npm run prd ``` -------------------------------- ### Install TarsCpp Environment Source: https://tarscloud.github.io/TarsDocs_en/benchmark/build.html Clone and build the TarsCpp framework from source. ```bash git clone https://github.com/TarsCloud/TarsCpp.git --recursive cd TarsCpp mkdir build cd build cmake .. make make install ``` -------------------------------- ### Initialize Communicator with Configuration File Source: https://tarscloud.github.io/TarsDocs_en/dev/tarscpp/tars-guide.html Initialize the communicator using a configuration file. Ensure the 'config.conf' file is accessible and correctly formatted. ```cpp TC_Config conf("config.conf"); CommunicatorPtr c = new Communicator(); //Initialize the communicator with a configuration file c-> setProperty(conf); ``` -------------------------------- ### Start and verify MySQL service Source: https://tarscloud.github.io/TarsDocs_en/installation/mysql.html Starts the MySQL service and checks its current status. ```bash systemctl start mysqld.service systemctl status mysqld.service ``` -------------------------------- ### Start Node.js App with Configuration File Source: https://tarscloud.github.io/TarsDocs_en/dev/tars.js/tars-node-agent.html Launch the application using node-agent and specify a TARS configuration file. This allows for centralized configuration management. ```bash $ node-agent app.js –config MTT.Test.conf ``` -------------------------------- ### TarsGo Client Implementation Source: https://tarscloud.github.io/TarsDocs_en/dev/tarsgo Example of initializing a communicator and calling a remote method using TarsGo. ```go package main import ( "fmt" "github.com/TarsCloud/TarsGo/tars" "TestApp" ) //tars.Communicator should only init once and be global var comm *tars.Communicator func main() { comm = tars.NewCommunicator() obj := "TestApp.TestServer.HelloObj@tcp -h 127.0.0.1 -p 10015 -t 60000" app := new(TestApp.Hello) comm.StringToProxy(obj, app) var req string="Hello World" var out string ret, err := app.TestHello(req, &out) if err != nil { fmt.Println(err) return } fmt.Println(ret, out) } ``` -------------------------------- ### Initialize Communicator with Direct IP/Port Source: https://tarscloud.github.io/TarsDocs_en/base/tars-concept.html Create a communicator and obtain a proxy by directly specifying server IP and port addresses. ```cpp Communicator *communicator = new Communicator(); HelloPrx helloPrx = communicator->stringToProxy("Test.HelloServer.HelloObj@tcp -h xxx -p yyy:tcp -h www -p zzz"); helloPrx->call(); ``` -------------------------------- ### Install Build Dependencies Source: https://tarscloud.github.io/TarsDocs_en/benchmark/build.html Install necessary development tools on Centos7 for source compilation. ```bash yum install glibc-devel gcc gcc-c++ bison flex cmake ``` -------------------------------- ### Customize Tars C++ Installation Path Source: https://tarscloud.github.io/TarsDocs_en/installation/source-windows.html Modify specific CMake and makefile files to change the default installation path for the Tars C++ framework and its components. This is necessary if you need to install the framework in a location other than the default. ```bash **modify tarscpp/cmake/Common.cmake** **modify TARS_PATH in tarscpp/servant/makefile/makefile.tars** **modify TARS_PATH in tarscpp/servant/makefile/tars-tools.cmake** **modify DEMO_PATH in tarscpp/servant/script/create_tars_server.sh** ``` -------------------------------- ### Example Server Configuration XML Source: https://tarscloud.github.io/TarsDocs_en/dev/tarsgo Illustrates a typical server configuration using XML format. This configuration includes settings for node, application, server name, paths, logging, and communication endpoints. ```xml enableset=Y setdivision=gray.sz.* node=tars.tarsnode.ServerObj@tcp -h 10.120.129.226 -p 19386 -t 60000 app=TestApp server=HelloServer localip=10.120.129.226 local=tcp -h 127.0.0.1 -p 20001 -t 3000 basepath=/usr/local/app/tars/tarsnode/data/TestApp.HelloServer/bin/ datapath=/usr/local/app/tars/tarsnode/data/TestApp.HelloServer/data/ logpath=/usr/local/app/tars/app_log/ logsize=10M config=tars.tarsconfig.ConfigObj notify=tars.tarsnotify.NotifyObj log=tars.tarslog.LogObj #timeout for deactiving , ms. deactivating-timeout=2000 logLevel=DEBUG ``` -------------------------------- ### Initialize CommunicatorConfig from file Source: https://tarscloud.github.io/TarsDocs_en/dev/tarsphp/Framework/tars-log.html Initialize the communicator configuration using a path to a configuration file. ```php $config = new \Tars\client\CommunicatorConfig(); $sFilePath = '{project}/src/conf'; //Configuration file path $config->init($sFilePath); ``` -------------------------------- ### Installation Script Output Source: https://tarscloud.github.io/TarsDocs_en/installation/source.html Expected console output upon successful installation of the Tars framework. ```text 2019-10-31 11:06:13 INSTALL TARS SUCC: http://xxx.xxx.xxx.xxx:3000/ to open the tars web. 2019-10-31 11:06:13 If in Docker, please check you host ip and port. 2019-10-31 11:06:13 You can start tars web manual: cd /usr/local/app/web; npm run prd ``` -------------------------------- ### Install TarsPHP Extension from Source Source: https://tarscloud.github.io/TarsDocs_en/dev/tarsphp/Environment/php.html Compile and install the phptars extension manually from the source code. ```bash cd tars-extension sudo phpize sudo ./configure sudo make sudo make install add extension = phptars.so in php.ini ``` -------------------------------- ### Create Tars Directory and Set Permissions Source: https://tarscloud.github.io/TarsDocs_en/installation/expand.html Use these commands to create the deployment directory for basic services and set ownership. Ensure you replace `${user}` with the appropriate username. ```bash cd /usr/local/app mkdir tars chown ${user}:${user} ./tars/ ``` -------------------------------- ### Install Swoole via PECL Source: https://tarscloud.github.io/TarsDocs_en/dev/tarsphp/Environment/php.html Use the PECL package manager to install the Swoole extension. ```bash pecl install swoole ``` -------------------------------- ### Create index.php Startup Entry Source: https://tarscloud.github.io/TarsDocs_en/dev/tarsphp/QuickStart/tars-websocket-server.html Initializes the Tars command handler for service startup. ```php run(); ``` -------------------------------- ### Quick Release Benchmark Service Source: https://tarscloud.github.io/TarsDocs_en/benchmark/build.html Deploy the benchmark service to the TarsWeb platform using the install script. ```bash ./install.sh webhost token adminsip nodeip ``` -------------------------------- ### Download TarsGo Framework Source: https://tarscloud.github.io/TarsDocs_en/env/tarsgo.html Navigate to the GOPATH directory and fetch the TarsGo source code. ```bash cd $GOPATH go get -u github.com/TarsCloud/TarsGo/tars ``` -------------------------------- ### Install Tars Deployment Tool Source: https://tarscloud.github.io/TarsDocs_en/hello-world/tars.js.html Global installation of the command-line tool required for packaging Tars services. ```bash npm install @tars/deploy -g ```