0
votes

I need to run a jar file when my Ubuntu 16.04 instance on GCP is ON. So I add a custom metadata:

enter image description here

but It's not working.

For testings, I have tried to generate files every time I turn off and on the VM, and startup script compiles them successfully.

EDITED: If I run this command from shell, it runs succesfully and port 4444 is opened.

Furthermore, the startup script ignores xvfb for the following example, but fuego_vins.txt and fuego_vins_exit.txt are deposited on /usr/bin:

#! /bin/bash
sudo touch /usr/bin/fuego_vins.txt
sudo apt-get update
sudo xvfb-run -a java -Dwebdriver.chrome.driver=/usr/bin/chromedriver -jar selenium-server-standalone-3.13.0.jar -port 4444
sudo touch /usr/bin/fuego_vins_exit.txt
1
Did you try without using sudo?night-gold
Yes. It still does not workMario M.
I am guessing this item: Your java environment variables, classlib, etc. are not setup when running as the startup.script service. You will need to set them manually before calling java. You can do this in your script. Also, xvfb-run - specify the full pathname.John Hanley
3 things: 1) startup scripts run as root, no need for sudo. 2) your script shows port 4444 but you said you run in shell and 444 opens, is this a typo or are you using the incorrect ports? 3) Can you provide the output of the serial port during the startup period, we should be able to see the startup script running and the output from there.Patrick W
It was a problem of paths and permissions. Thanks @JohnHanley Patrick. Now, startup script runs and port 4444 is opened.Mario M.

1 Answers

1
votes

I tested it using:

  • xvfb version: xorg-server 1.18.4
  • selenium-server-standalone-3.9.1.jar

from /usr/bin/selenium

-rwxr-xr-x 1 root  root 153 Nov 27 08:31 run   
-rwxr-xr-x 1 user  user 23428464 Feb  7  2018 selenium-server-standalone-3.9.1.jar

I created script into /home/user folder into VM then I ran it from startup-script.

startup-script:

sudo apt-get update
sudo apt-get upgrade
sudo /usr/bin/selenium/run

from the Serial port 1 (console) output for instance:

Ubuntu 16.04.5 LTS instance ttyS0

instance-2 login: Nov 27 09:00:43 instance-2 startup-script: INFO startup-script: 2018-11-27 09:00:43.766:INFO::main: Logging initialized @2790ms to org.seleniumhq.jetty9.util.log.StdErrLog
Nov 27 09:00:44 instance-2 startup-script: INFO startup-script: 2018-11-27 09:00:44.100:INFO:osjs.Server:main: jetty-9.4.7.v20170914, build timestamp: 2017-11-21T21:27:37Z, git hash: 82b8fb23f757335bb3329d540ce37a2a2615f0a8
Nov 27 09:00:44 instance-2 startup-script: INFO startup-script: 2018-11-27 09:00:44.158:WARN:osjs.SecurityHandler:main: [email protected]@45ca843{/,null,STARTING} has uncovered http methods for path: /
Nov 27 09:00:44 instance-2 startup-script: INFO startup-script: 2018-11-27 09:00:44.166:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@45ca843{/,null,AVAILABLE}
Nov 27 09:00:44 instance-2 startup-script: INFO startup-script: 2018-11-27 09:00:44.230:INFO:osjs.AbstractConnector:main: Started ServerConnector@93c3e76{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
Nov 27 09:00:44 instance-2 startup-script: INFO startup-script: 2018-11-27 09:00:44.231:INFO:osjs.Server:main: Started @3256ms

I could not run it, with selenium-server-standalone-3.13.0.jar; so I'll try later. Hope it could be useful to you.