Otu esi etinye sava ozi Centrifugo na Ubuntu 20.04

Centrifugal bụ ihe nkesa ozi ozugbo enwere ike ịbelata. Centrifugo na-arụkọ ọrụ yana nkwado ndabere ngwa edere n'asụsụ mmemme ọ bụla. Ọ na-arụ ọrụ dị iche iche ma na-edobe njikọ Websocket ma ọ bụ njikọ SockJS n'aka ndị ahịa ngwa. Mgbe ịchọrọ ibugara ndị ahịa gị ihe omume ozugbo, ị na-ebipụta ya na Centrifugo API. Centrifugo wee gbasaa mmemme ahụ nye ndị ahịa niile nwere mmasị na mmemme a (ya bụ, ndị ahịa debanyere aha na ọwa mmemme).

N'ime ntuziaka a, ị ga-amụta otu esi etinye Centrifugo na sava Ubuntu 20.04.

Prerequisites

  • Nweta mgbọrọgwụ ma ọ bụ ikike sudo.
  • Ubuntu 20.04 LTS. (21.04 na-arụ ọrụ na ntuziaka a)
  • WGET iwu
sudo apt update && sudo apt upgrade -y \
sudo apt install wget

Advertisement


Budata Centrifugo

Ebe nchekwa Ubuntu anaghị agụnye Centrifugo, yabụ ị ga-ebudata isi iyi na ebe nchekwa GIT ya. A na-atụ aro ka ịlele ibe mwepụta ka ihe atụ ntuziaka dị n'okpuru nwere ike bụrụ ihe ochie. Ozugbo ị gara na Ibe mwepụta wee nweta njikọ kacha ọhụrụ, pịnye ihe ndị a.

wget https://github.com/centrifugal/centrifugo/releases/download/v2.8.5/centrifugo_2.8.5_linux_amd64.tar.gz

Ozugbo nbudata nbudata ahụ, wepụ faịlụ ebudatara site na ịpị iwu na-esonụ.

tar -xvzf centrifugo_2.8.5_linux_amd64.tar.gz

Wụnye Centrifugo

Ugbu a, ị ga-ebuga ọnụọgụ Centrifugo gaa na / usr/bin ndekọ:

sudo mv centrifugo /usr/bin

N'ikpeazụ, ị ga-enyocha ụdịdị ahụ iji hụ na etinyere ya na ihe niile na-arụ ọrụ nke ọma ruo ugbu a.

centrifugo version

Ihe atụ mmepụta:

~$ centrifugo version
 Centrifugo v2.8.5 (Go version: go1.16.4)

Advertisement


Hazie Centrifugo

Iji hazie Centrifugo, ọ dị mfe. Nke mbụ, ịkwesịrị ịmepụta faịlụ nhazi, mana kama, ka anyị mepụta ndekọ iji dobe faịlụ nhazi.

sudo mkdir -p /etc/centrifugo && cd /etc/centrifugo

Mgbe ahụ ị nwere ike ịmepụta faịlụ nhazi site na ịpị.

sudo centrifugo genconfig

Mgbe itinyechara iwu a, ọ ga-ewepụta faịlụ config.json na ndekọ aha ị kọwapụtara.

Ị nwere ike nyochaa faịlụ ahụ site na ịpị iwu CAT na-esote.

cat config.json

Ị ga - enweta mmepụta ndị a:

:/etc/centrifugo$ cat config.json
 {
   "v3_use_offset": true,
   "token_hmac_secret_key": "4bfd92e6-9526-474a-877b-0730c55f37ea",
   "admin_password": "1fe1f1f3-df96-4bfe-b383-bfe7a8408660",
   "admin_secret": "5ce4d2cd-2db9-4ad9-a6c6-6c6dfe1160a6",
   "api_key": "fcb8ff4f-64be-4918-bb57-711fdfc852cb",
   "allowed_origins": []
 }

Jide n'aka gị"admin paswọọdụ", dịka ị ga-achọ ya ịbanye na UI weebụ. A na-atụ aro ịchekwa ihe niile.

Mepụta faịlụ ọrụ Sistem maka Centrifugo

Akụkụ ikpeazụ nke ịtọlite ​​​​Centrifugo na-ekepụta faịlụ ọrụ Systemd. Anyị ga-eji nchịkọta ederede nano maka nke a.

sudo nano /etc/systemd/system/centrifugo.service

Ozugbo ị nwere nchịkọta akụkọ nano na faịlụ mepere emepe, pịnye ntinye na-esonụ n'ime faịlụ ahụ.

[Unit]
 Description=Centrifugo Websocket Server
 After=network.target syslog.target
 [Service]
 LimitNOFILE=30000
 ExecStartPre=/usr/bin/centrifugo checkconfig --config /etc/centrifugo/config.json
 ExecStart=/usr/bin/centrifugo --config /etc/centrifugo/config.json --admin
 ExecReload=/bin/kill -HUP $MAINPID
 ExecStop=/bin/kill -SIGTERM $MAINPID
 TimeoutStopSec=5
 KillMode=control-group
 RestartSec=2
 Restart=always
 SyslogIdentifier=centrifugo
 [Install]
 WantedBy=multi-user.target
 Alias=centrifugo.service

Pịa CTRL+O, wee tinye "Y", nke ga-echekwa ntinye data n'ime faịlụ ahụ, wee pịa CTRL+X ka ịpụ na faịlụ ahụ.

Ugbu a, ị ga-achọ ibugharị daemon, nke a na-eme site na iwu na-esonụ.

sudo systemctl daemon-reload

Na-esote, malite usoro usoro na mgbe ị nọ ya, mee ka ọrụ ahụ dị na mmalite ma ọ bụrụ na-amasị gị.

sudo systemctl start centrifugo && sudo systemctl enable centrifugo

Ozugbo amalitere ọrụ ahụ, lelee ọrụ ahụ ka ị hụ na ihe niile na-arụ ọrụ nke ọma.

systemctl status centrifugo

Ị ga-ahụ mmepụta ndị a:

● centrifugo.service - Centrifugo Websocket Server
      Loaded: loaded (/etc/systemd/system/centrifugo.service; disabled; vendor preset: enabled)
      Active: active (running) since Wed 2021-06-23 00:47:38 PDT; 4s ago
     Process: 20356 ExecStartPre=/usr/bin/centrifugo checkconfig --config /etc/centrifugo/config.json (code=exited, status=0/SUCCESS)
    Main PID: 20361 (centrifugo)
       Tasks: 7 (limit: 4617)
      Memory: 8.0M
      CGroup: /system.slice/centrifugo.service
              └─20361 /usr/bin/centrifugo --config /etc/centrifugo/config.json --admin
 Jun 23 00:47:38 ubuntu systemd[1]: Starting Centrifugo Websocket Server…
 Jun 23 00:47:38 ubuntu systemd[1]: Started Centrifugo Websocket Server.
 Jun 23 00:47:38 ubuntu centrifugo[20361]: {"level":"info","version":"2.8.5","runtime":"go1.16.4","pid":20361,"engine":"Memory","gomaxprocs":2,"time":"2021-06-23T00:47:38-07:>
 Jun 23 00:47:38 ubuntu centrifugo[20361]: {"level":"info","path":"/etc/centrifugo/config.json","time":"2021-06-23T00:47:38-07:00","message":"using config file"}
 Jun 23 00:47:38 ubuntu centrifugo[20361]: {"level":"info","time":"2021-06-23T00:47:38-07:00","message":"serving websocket, SockJS, API, admin endpoints on :8000"}
 ~

Site na ndabara, ọrụ Centrifugo na-ege ntị ọdụ ụgbọ mmiri 8000.


Advertisement


Jiri ogwe nchịkwa mee Centrifugo

Ugbu a, ị nwere ike ịbanye na panel UI weebụ gị. Enwere ike ime nke a site na imepe ihe ndị a na ihe nchọgharị gị. Cheta, ịchọrọ paswọọdụ sitere na faịlụ nhazi dịka ekwuru na mbụ na ntuziaka.

http://IP-ADDRESS:8000
 or
 http://example.com:8000
Nbanye Centrifugo

Mgbe ịbanyechara, ị ga-ahụ ozi izugbe gbasara ọrụ Centrifugo na UI.

Centrifugo webụ ui

Okwu na mmechi

N'ime ntuziaka ahụ, ị ​​mụtara ka esi etinye na ịtọ Centrifugo. Ngwa n'onwe ya bụ ihe pụrụ iche maka ịrụ ọrụ n'ụdị sistemu azụ azụ ebe ị nwere ike ịnwe ọtụtụ sistemụ dị iche iche na gburugburu mmepụta. Akụrụngwa n'onwe ya bụ nke ọma mepụtara yana maka nkata ozi ozugbo n'efu.

Enwere ike ịchọta ozi gbasara ntọlite ​​​​ndị ahịa na ntinye aka na Centrifugo akwụkwọ.

Ahapụ a Comment