기본 콘텐츠로 건너뛰기

탄력받은 김에 socketcluster 호스팅 서비스인 baasil.io 도 써보았다.

한달 무료 플랜이 있어서 광속가입.
나는야 시스템 어드민이기 때문에 유저따윈 얼마든지 만들 수 있다.

철자가 좀 헷깔린다. baasil.io다. 다소 웹페이지가 엉성한 느낌은 있다.
이런건 망하기 전에 잽싸게 빨대 꽂는 것이 인지상정.

아마도 대부분 유료를 겁내고 자신의 계정이 한달짜리 트라이얼로 소모되는게 아까우실거라고 생각하여 대신 가입해봄 -_-)v

가입 후 Email validation을 하고 나면
어서와. 소켓클러스터는 처음이지?

매우매우매우 심플하다.
Baasil.io manages your real-time infrastructure for you without compromising on flexibility. We provide you with a highly scalable, open source boilerplate (SCC) which you can modify as you like and then deploy to your own Kubernetes environment/cluster using a single command. The boilerplate we provide is designed to scale seamlessly across up to 1000 machines/hosts.
For the standard plan, Baasil.io gives you an isolated environment on a shared Rancher control panel. This setup is ideal if you have a relatively small number of machines (e.g. 1 to 20 hosts in your cluster) and are happy to look after your cluster using Rancher. If you would like to support more than 20 machines, want a completely hands-off experience when it comes to your infrastructure, or want your own dedicated Rancher control panel - We can make it happen with our flexible enterprise plan. If you would like to updgrade to the enterprise plan, you can contact us here.
You need to link your Baasil.io account to a valid GitHub account here before you can create your Rancher environment/cluster.
라고 한다.
Rancher라는 걸 쓰려면 깃허브 계정과 연동하라고 하는데 일단 패스
Try It을 보니
서비스키!! 키를 내놓으라!

오호. 서비스 키라는 걸 제공. 클라이언트 사이드에서 사용할 수 있다.
근데 크롬에서 개발자 콘솔 여는 단축키는 Cmd + Shift + J on OSX 아니야. Cmd + Option + J 라구!
<script src="https://baasil.io/socketcluster.js"></script>
요렇게 클라이언트에 붙이고
var socket = socketCluster.connect({
    query: {
      serviceKey: '섭수키:main'
    },
    channelPrefix: '섭수키:main#',
    hostname: 'service.baasil.io',
    port: 443,
    secure: true
  });
이렇게 접속해서

Subscribe
var myChannel = socket.subscribe('my-channel-name');
Watch
myChannel.watch(function (data) {
    // Handle incoming channel data here. You can set up multiple watchers per channel.
    console.log('myChannel data:', data);
  });
Unwatch
// The handler argument is optional (a function) - If not provided, it will unbind all watchers.
  myChannel.unwatch(handler);
Publish
myChannel.publish({foo: 'This is some JSON data'}, function (err) {
    // Callback to indicate whether or not publish was successful.
  });
Unsubscribe

myChannel.unsubscribe();
Check channel subscription state

myChannel.state // Can be 'unsubscribed', 'subscribed' or 'pending'
Check socket connection state
socket.state // Can be 'open', 'connecting' or 'closed'
Other useful operations...
Get array of watchers
// Get array of functions which are watching that channel.
  myChannel.watchers();
Subscribe again...
// Subscribe to a channel which was previously unsubscribed.
  myChannel.subscribe();
Get channel reference from socket
// This will not create any new subscriptions - Just get a channel reference.
  var myChannel = socket.channel('my-channel-name');
Get list of all subscribed channels
// Returns an array of channel names which are currently subscribed.
  // If the second argument is true, it will include channels which are pending subscription.
  socket.subscriptions('my-channel-name', true);
꿀팁을 마구 대방출.
뭐 이것만 알면 되겠네.
세상 참 좋구만.

그 다음은 https://docs.baasil.io/ 를 보고 CLI 도 설치해본다.
npm install -g baasil
설치 끗.
하나 만들어 봐야지. 그전에 docker가 있어야 하니 꼭 체크하고.
baasil create jwaujijangjiji 
해보니
Creating app structure...
[Success] Baasil.io app '/Users/spectrum/Documents/js/_app/jwaujijangjiji' was setup successfully.
끗.
node.js 가 그렇지 뭐;
실행해보자.
$ cd jwaujijangjiji
$ baasil run
Unable to find image 'socketcluster/socketcluster:v5.1.2' locally
v5.1.2: Pulling from socketcluster/socketcluster
5c90d4a2d1a8: Pull complete
ab30c63719b1: Pull complete
29d0bc1e8c52: Pull complete
f222342d2902: Pull complete
27808f091869: Pull complete
a5f3825caa0a: Pull complete
Digest: sha256:d466ab21339117e03aad3f97583cdb3320a4520f3d515f8dd6c1bfd19dba1c75
Status: Downloaded newer image for socketcluster/socketcluster:v5.1.2
2c597396d46e4c60348b5abfea8bc95bf099b1be0f9c9313c21859ff386d481e
[Success] App 'baasil01' is running at http://localhost:8000
docker 리파지터리에서 socketcluster 이미지를 땡겨온 다음 8000로 실행한다.
아주 좋아!
baasil --help
Usage: baasil [options] [command]
Options:
  -v            Get the version of the current Baasil.io installation
  --help        Get info on how to use this command
  --force       Force all necessary directory modifications without prompts
Commands:
  create <app-name>             Create a new boilerplate SCC app in working directory
  run <path>                    Run app at path inside container on your local machine
  restart <app-path-or-name>    Restart an app with the specified name
  stop <app-path-or-name>       Stop an app with the specified name
  list                          List all running Docker containers on your local machine
  logs <app-path-or-name>       Get logs for the app with the specified name
  deploy <app-path>             Deploy app at path to your Baasil.io cluster
  deploy-update <app-path>      Deploy update to app which was previously deployed
  undeploy <app-path>           Shutdown all core app services running on your cluster
커맨드 라인 내용을 보니 대략 이렇다.
필요한 것만 딱 들어있네.
공통인 부분은 죄다 제외하고 서버 사이드엔 worker.js 와 package.json 나머지 client는 public안에 다 몰아놓았다.
안그래도 간단한데 더욱 간단하다.
docker와 kurbernate가 세상을 정말 많이 바꿨구나. 이젠 이런게 아무렇지도 않군.

다짜고짜 deploy 때려보자.
dockerhub 계정을 요구한다.
만들어만들어~
$ baasil deploy
? Enter your DockerHub username: bsio20161210
? Enter your DockerHub password: *********
? Enter the number of workers for each SocketCluster instance (Default: 1): 4
? Enter the number of brokers for each SocketCluster instance (Default: 1):
? Enter the Docker image name without the version tag (Or press enter for default: bsio20161210/
baasil01):
? Enter the Docker version tag for this deployment (Default: v1.0.0):
Sending build context to Docker daemon 228.9 kB
Step 1 : FROM node:6.3.0-slim
6.3.0-slim: Pulling from library/node

worker는 4개!
[Error] Failed to deploy the 'baasil01' app. Command failed: kubectl create -f /Users/spectrum/Documents/js/_app/csjBootstrap/baasil01/kubernetes/scc-broker-deployment.yaml
실패한다.
쩝, github 연동 먼저 해야지.

https://baasil.io/#!/dashboard?main-tab=account 에서 github account 넣어주고
https://baasil.io/#!/dashboard?main-tab=infrastructure 로 돌아오면 Rancher 생성이 활성화 된다.

TADA!
지금부터 대쉬보드인가!
생성생성

좋다. host 생성하자.
이것저것 눌러보자. 음... 잘만들었네.
EC2나 Azure는 쓰지 않는다. Custom으로 ㄱ

잘모르니까 디폴트.
5번에 Copy, paste, and run the command below to register the host with Rancher: 부분 아래에 있는 명령을 복사해서 터미널에 붙여넣자.

Unable to find image 'rancher/agent:v1.0.2' locally
v1.0.2: Pulling from rancher/agent
5a132a7e7af1: Pull complete 
fd2731e4c50c: Pull complete 
28a2f68d1120: Pull complete 
a3ed95caeb02: Pull complete 
7fa4fac65171: Pull complete 
33de63de5fdb: Pull complete 
d00b3b942272: Pull complete 
Digest: sha256:b0b532d1e891534779d0eb1a01a5717ebfff9ac024db4412ead87d834ba92544
Status: Downloaded newer image for rancher/agent:v1.0.2
5cc13082b79f9b58a488c456fdd1500de6b7f9450bd6ab42aa89517088c61336
docker: Error response from daemon: Mounts denied: 
The path /var/lib/rancher
is not shared from OS X and is not known to Docker.
You can configure shared paths from Docker -> Preferences... -> File Sharing.
See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.
..
오류가 나는데
sudo docker run -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.0.2 https://localhost:8000/v1/scripts/ㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌ:ㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌㅌ
ㅉㅉㅉㅉㅉㅉㅉㅉㅉㅉㅉㅉㅉㅉㅉㅉㅈ
이런식으로 주소를 localhost기준으로 바꿔주자. 디폴트는 8000번 포트.

아으 여기까지 해봤는데 지친다.
local로만 해보고 이미지 떠서 다른데 호스팅 하는게 낫겠어. 귀찮네.

#짐싸자


댓글

이 블로그의 인기 게시물

세상 간단한 https(+secured websocket): Caddy

nginx, apache2 같은 걸로 매번 certbot 연동을 통해 https 하는게 지겨워서 알아보니 Caddy라는게 있더라. 설치법은 강하게 크기 위해 알아서 해본다. # cat /etc/caddy/Caddyfile your.shitty.site:8123 {   proxy / localhost:9123 {     websocket     transparent   } } 이건 외부에서 8123으로 들어오는 걸 내부적으로 9123로 맞춰서 https 맞춰주는 reverse proxy. 만일 port를 생략하면 # cat /etc/caddy/Caddyfile your.shitty.site {   proxy / localhost:9123 {     websocket     transparent   } } 기본포트인 443으로 되어 https://your.shitty.site 로 접속이 된다. 요새 말썽이던 cloudflare 버리고 netlify domain이랑 caddy를 쓰니까 앓던 이가 빠진 느낌. 이 조합은 당분간 계속 써야겠다 싶다.

LG G Pro 2 Custom Rom +Rooting 기록

선 루팅 https://forum.xda-developers.com/lg-g3/general/guide-root-lg-firmwares-kitkat-lollipop-t3056951 1.2버전 스크립트 모드로. echo Looking for LG serial port.. echo. adb.exe wait-for-device 여기에서 정체 상태여서 강제로 adb kill-server 했더니 알아서 재부팅하심. 폰에선 "펌웨어 업데이트"화면이 나오고 Phone found at COM5! Rooting phone.. If you don't see the SuperSu installer script runs within about a minute, then the root failed. Author : blog.lvu.kr SPECIAL COMMAND : ENTER, LEAVE ## 이런 상황이 됨. #이 느린 속도로 하나씩 증가하고 있음. 한 시간 기다려도 성과없음. 뭐 몇번해봐도 안되고 결국 불안하긴 하지만 kingroot.net  로 설치 롤리팝이니까  https://drive.google.com/file/d/0B4kfGU1z_PClQ3AyM2lKOGR1S3M/view  이걸 받아서 압축 풀기. d838recovery.bat 만 있어서 당황스럽긴한데 실행하고 1번 하니까 리커버리 모드 진입까진 잘 되는 듯. adb sideload 라는게 있어서 해봄. Advance에서 adb sideload 선택하고 USB연결한 PC에서 adb sideload RR-N-v5.8.5-20171010-d838-Final.zip 하니까 착착 잘 진행됨. 이제 흉측한 U+LTE 가 없어짐. ㅇㅋ 군더더기 없고 깔끔한데 남은 건 gapps 를 설치해야함. http://opengapps.org/  를 권해줘서 갔는데 지옥 느림. ARM + 7.1 + stock 이 기본이...

Google Daydream 소감

드디어 V30 사은품인 Daydream이 왔다. 낭랑한 벨과 함께 무심한 듯 시크하게 툭 던지고 가시는 택배느님. 수령까지 두달 걸렸다. 눈을 뜨고 꿈꿔 보세요. 여기가 눈감으면 코베어 간다는 서울인가? 주황색면으로 열면 된다. 컨트롤러의 만듦새는 아주 좋다. 기존에 나와있는 사진엔 가로 머리끈만 있어서 똥머리한 언니들도 막 쓰고 플레이하고 그랬는데 실제로 보니 이중 끈이었다. 보통 돌아다니는 착샷 Daydream 설치 - 실행 - 폰 장착 - 컨트롤러 페어링 - VR진입까지 과정을 쉽게 하려고한 노력이 보였음. NFC로 데이드림뷰어에 폰을 장착하면 자동으로 인식하여 데이드림 앱이 실행되는 경험은 꽤 괜찮았음. 컨트롤러는 크기, 그립감 면에서 매우 훌륭하고 인식률, 반응속도 모두 만족스러움. 홈버튼으로 시선을 재 조정하는 발상은 좋은데 왼쪽 오른쪽이 앱마다 조금 혼란스럽고 상하방향 캘리브레이션은 안된다. 이 부분에서 좌절했다. 누워서 넷플릭스를 보는 건 다른 방법을 찾아보아야한다는 소리. 알고보니 이런 건 Youtube이나 Netflix, Skybox player 등등에서 테스트해본 결과 자체 앱에서 지원하고 있다. Netflix는 void theater라는 것이 있는데  <출처:  https://元ボクサーの一念発起.com/2018/05/10/oculus-go/ > Netflix app에서 요렇게 눈송이 같이 생긴 아이콘을 컨트롤러로 찍고 들어가면 화면만 덩그러니 나오고 스티어링휠(자동차 핸들) 모양 아이콘을 선택하고 누으면 자연스럽게 조정이 되었다. Youtube나 Skybox앱의 경우 아예 컨트롤러에서 꾹 누르고 화면 이동하는게 가능해서 편리. 게임은 이것저것 해봤는데 Rez Infinite이 최고. 아니 이건 그냥 전 VR 기기를 통틀어서 Rez Infinite이 최고가 아닐까 싶음;;; 결론,  1. 누워서 보기 잘된다. 2. ...