Google cloud startup script on custom image - java

I want to start an ubuntu in google cloud. my problem is when I want to run a startup script like:
Metadata.Items item2 = new Metadata.Items();
item2.setKey("startup-script");
item2.setValue("my script....");
the problem is that my startup script never running. Has anybody idea how can I run startup script on custom image automatically?
I have preinstalled cloud-init on my image.

In the Google Developers' Console, go your Ubuntu instance settings.
Then add a new Custom Metadata key-value pair.
Key: startup-script
Value: your script or a URL of where to find it
Checked it works with own Ubuntu custom image. Try with something simple at the beginning like
echo `date` >> /tmp/startup-script

Related

Karaf command not found exception how to troubleshoot?

Downloaded karaf 4.0.9 just following getting started doc but keep getting this
org.apache.felix.gogo.runtime.CommandNotFoundException: Command not found: feature:install
whenever i try to do feature:install wrapper from shell
Finding it very difficult to find any help or doc how to trouble shoot? is it a permissions thing? I chowned everything to the same user for simplicity...
Is distribution missing a library? Where do i get it/put it?
New to karaf... Following this: http://karaf.apache.org/manual/latest/#_installation
Just trying to get some basic JDBC/JMS stuff working, install drivers, recieve some msgs, query db, etc
Spent a few hours of reading docs + trial and error to figure this out:
ssh karaf#localhost -p 8101
Will get you full admin shell, apparently this isn't available if you just ./shell from KARAF_HOME/bin
You can check your configurations in users.properties in karaf/etc folder .
Open karaf shell using admin rights.
Start Karaf shell from its bin folder.
Now run karaf console using below command.
ssh username#localhost -p8101
now you can run any command of karaf shell.

Not able to in initiating x11, java handling error

I have a Solaris-10 non global zone. I am using MobaXterm. I login on box with root and then "su - caddrd" and then "/usr/local/bin/sudo -u cadwebppc /cad/envs/qa-cm/cadwccDomain/ucm/cs/bin/UserAdmin". This is supposed to open a GUI console, but it is failing and I am not able to figure out. Can somebody help on this ?
It gives me error -
No X11 DISPLAY variable was set, but this program performed an operation which requires it
Update - I am refining this question more. I am able to run xclock via root, via caddrd and via cadwebppc also. But when I am using it with sudo, it is giving error. So it seems something like, having issue with passing variables.
Try to set DISPLAY variable. If you are on the main display this command should do:
export DISPLAY=:0.0
I found this link to be helpful:
http://www.snapdba.com/2013/02/ssh-x-11-forwarding-and-magic-cookies/
When switching to my oracle user (or in your case caddrd) the X11 forwarding information is lost. You can use xauth to copy it to the user's .Xauthority file
So, as root do:
echo xauth add xauth list ${DISPLAY#localhost}
copy this command, sudo to your user and execute this command there.

specify port for standalone mode in PlayFrameWork 2.2.1

I have two apps developed in PlayFrameWork 2.2.1 named:
1. helloWorld_88
2. helloWorld_99
For helloWorld_88:
I want to build this app run (standalone) on port 88.
For helloWorld_99:
I want to build this app run (standalone) on port 99.
As I know, using "dist" task will help me to build a standalone version of apps but I don't know how to specify the port.
Can anybody advice step by step.
Thanks
Rado
Hi Rado, Thanks for your quick reply.
I have already try this before I post the question, but the port always 9000.
See bellow output from the command line (Windows)
E:\Deploy\helloworld_88\bin>helloworld_88 -Dhttp.port=88
Play server process ID is 2216
[info] play - Application started (Prod)
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
Any other idea
Thanks
I assume that you have built both applications using "play dist" command and that you run them using generated "bin/helloWorld_88" and "bin/helloWorld_99" script files on Linux. (for Windows these files are named "bin/helloWorld_88.bat" and "bin/helloWorld_99.bat")
Go to the "bin" folder and run:
helloWorld_88 -Dhttp.port=88
and then for the second application do:
helloWorld_88 -Dhttp.port=99

PHP - Error installing JavaBridge.war

I'm trying to install JavaBridge as I want to make connections between my php files and Java files.
I need my php request a GET method to Java file, and Java file will get the ID and run some script and return with an ARRAY.
I tried to install JavaBridge, but I get errors while trying to excess to localhost:8080/JavaBridge
javax.servlet.ServletException: php.java.bridge.http.FCGIConnectException: Could not connect to server
php.java.bridge.http.FCGIConnectException: Could not connect to server
java.io.IOException: File \\.\pipe\C:\apache-tomcat-7.0.39\temp\JavaBridge939398813756155712.socket not writable
java.io.IOException: PHP not found. Please install php-cgi. PHP test command was: [php-cgi, -v]
I didn't show out all the errors here, I showed only the first line of each root cause.
I will give more details in my setup.
I'm using XAMPP all the time, with PHP, MySQL in the XAMPP.
Then I just installed Tomcat inorder to install JavaBridge.
I copied JavaBridge.war into c:/tomcats/webapps, copied JavaBridge.jar and php-servlet.jar into c:/tomcats/lib
I assume the problems should lies with the PHP, but I don't know how to fix it as well.
Install PHP again? but I'm not sure too.
Whats the problem with my setup?
Or is there others way to make connections between PHP and Java as what I stated above?
Thank you.
Have you enabled php-cgi?
Here's how u can do it. Go to: xampp\apache\conf\extra\httpd-xampp.conf and uncomment this:
<FilesMatch "\.php$">
SetHandler application/x-httpd-php-cgi
</FilesMatch>
<IfModule actions_module>
Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
</IfModule>
Restart Apache & Tomcat.

New relic on Heroku, how to get it to work?

I have deployed a Scala, play framework, application on Heroku.
And I have added the new relic add-on to my app.
I have followed the Java guide as Scala runs on the Java VM.
$ heroku addons:add newrelic:standard
-----> Adding newrelic:standard to ... done, v7 (free)
Unziped newrelic to newrelic in the application
$ git add newrelic
$ git commit -m 'add newrelic'
$ heroku config:add JAVA_OPTS='-Xmx384m -Xss512k -XX:+UseCompressedOops -javaagent:newrelic/newrelic.jar'
$ git push heroku master
Now to the problems. First when I accessed the add on I had to create a new account on new relic with new password and it wanted my credentials? Is this correct? Shouldn't my Heroku account suffice, I later think it started to work.? Strange process so now I believe I have two accounts. In Herokus page my account is standard hourly and in new relics it's standard lite.
I don't understand how to see my performance stats. I actually think that the new relic isn't set up correctly?
One absurd thing is the new relics homepage which says not sufficient permissions on everything except "tell a friend and earn bucks" not even support works WTF.
I have attached two screenshot with my credentials masked. can anyone comment if they look like they should or if the new relic has set up itself incorrectly?
You should be able to use New Relic through the heroku interface without creating a separate account.
Once you're app is deployed with the agent, and has gotten a few requests you should start seeing data in the interface.
The agent does create a log (I believe you can get output via heroku logs) so that might also help you troubleshoot it.
I'd suggest opening a support ticket on http://support.newrelic.com.
This could be happening because your hosted application does not have the right credentials (e.g license key) provided by newrelic.
Did you update the default newrelic.yml file obtained from the 'newrelic.jar' extract? You can obtain your app's license key in the account settings menu when accessing newrelic through the heroku interface (your 1st screenshot). Then set the following config vars on heroku;
NEW_RELIC_LICENSE_KEY="your license key"
NEW_RELIC_APP_NAME="your app name"
Don't forget to set the appropriate RACK_ENV config var too e.g RACK_ENV=production
Then update your newrelic.yml file by finding and changing the following lines;
license_key: '<%= license_key %>' to license_key: '<%= ENV["NEW_RELIC_LICENSE_KEY"] %>'
app_name: My Application to app_name: '<%= ENV["NEW_RELIC_APP_NAME"] %>'
app_name: My Application (Development) to app_name: '<%= ENV["NEW_RELIC_APP_NAME"] (Development) %>'
app_name: My Application (Staging) to app_name: '<%= ENV["NEW_RELIC_APP_NAME"] (Staging) %>'
Here is a sample newrelic.yml file with environment vars set.
You should be able to access new relic from heroku interface after you've pushed your changes.
Check whether you find anything in the heroku logs with heroku logs. Also, you can increase the log level of new relic by setting the system properties newrelic.config.log_level and newrelic.debug. Also note that after creation of a new account or after password changes it takes a while until the changed credentials are propagated.
To set a finer log log level:
$ heroku config:set JAVA_OPTS=”-Xmx384m -Xss512k -XX:+UseCompressedOops -Dfile.encoding=UTF-8 -javaagent:target/staged/newrelic-agent-2.20.0.jar -Dnewrelic.bootstrap_classpath=true -Dnewrelic.config.file=./conf/newrelic.yml newrelic.config.log_level=finer newrelic.debug=true”
Make sure to not run with that in production. It produces quite a lot of logs.
See our blog post about how to setup New Relic with Play 2.1/Scala on Heroku: http://techblog.nezasa.com/2013/08/performance-monitoring-of-nezasa-with.html
When I attempted to use New Relic on Heroku I was prompted to enter credit card information
$ heroku addons:add newrelic:standard
but I just exited out and the logging for my Rails application is working*. Note that depending on your New Relic settings you may just be logging locally (default for development mode does not log to the cloud but is accessible locally).
Sorry to pollute this thread with Ruby stuff, but you may find something similar with regards to Heroku and New Relic.
*update: I had the same issue again when deploying another application and realized that to use the Heroku New Relic add-on you have to provide credit card information, but if you just directly instrument your application you do not have to give credit card information. YOu do have to have created an account already, though.

Categories

Resources