ニックジャガー日記

勝手気ままだけど自分に素直なブログ

楽しく思えるのが一番の進歩

Webの自動巡回を確かめようと、ubuntuVirtualBoxを入れて、Vagrantで構成して、色々試した。

 

一通り終わってから、今度はいよいよAWSへ。

これが最終的な目的だったから。

 

AWSのEC2インスタンスをAWSLinuxにして、はて、ここからseleniumを動かすには?うん?GUIがいる?

 

ってなわけで、EC2インスタンスGUI化するのに、すごく時間がかかった。

aws.amazon.com

 

公式ページに書いてある!すごいすごい。と思って、やってみた。

まずはVNCがわからない。そこでVNCを調べてみる。

www.ipentec.com

 

ちなみにAmazonLinuxは基本CentOSなのでこれでいいはず。

最初にAWSの説明書通りにやってみると、MATE(マテ)の画面が現れず、ただ青い画面が出るだけ。ここでとっても詰まった。

 

最終的にはVNCの画面セッションの番号の問題と判明。

.1というセッションでなく、思い切って.3のセッションにしたら見事にMATEの画面が出た。あと、この記述が一番大事みたい。

 

# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/vncserver@.service
# 2. Edit <USER> and vncserver parameters appropriately
#   ("runuser -l <USER> -c /usr/bin/vncserver %i -arg1 -arg2")
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:<display>.service`
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, you should
# limit connections to the local host and then tunnel from
# the machine you want to view VNC on (host A) to the machine
# whose VNC output you want to view (host B)
#
# [user@hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB
#
# this will open a connection on port 590N of your hostA to hostB's port 590M
# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).
# See the ssh man page for details on port forwarding)
#
# You can then point a VNC client on hostA at vncdisplay N of localhost and with
# the help of ssh, you end up seeing what hostB makes available on port 590M
#
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
#
# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel.  See the "-via" option in the
# `man vncviewer' manual page.


[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l penta -c "/usr/bin/vncserver %i"
PIDFile=/home/penta/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target

 この例ではpentaになってるけど、ここをec2-userにすると見事に動いた。

vncclientはubuntuからなので、Remminaを使用。IP:3とEC2につなぐと見事にデスクトップ画面が出て感動した。

 

MATEは動作が軽くていい。

さて、ここからまた自動実行をやってみることになる。

 

詰まるととても窒息感があるけれど、しばらく時間を置いて、もう一度何気に見てみるとわかり始めることが多くなった。

 

エラー内容を見たり、WEBで調べて違いを調べたり。

そのコツが少しずつわかってきたかな。

 

なんだかんだいって、こういうのが楽しいのである。

 

072/100

#100DaysOfCode