I would like to build a centOS 7 instance on AWS and install Apache to build web server.
After that, I would like to modify the config file, /etc/hosts and /etc/httpd/conf.d/test.conf where test.conf is created by me.
Can I use java to modify the file directly? Or I should create the file and replace the old file on instance? I am little bit confused for the feasibility. Please someone help.
There seem to be a few questions here, so I've split them out.
Q: Can I use programming language X to modify a file on the local filesystem?
A: Yes, with very few exceptions. For Java, yes (if the instance has a JRE).
Q: Should I use Java?
A: Probably not the first choice (you could probably do what you need in a shell script at launch).
Q: Should I create the Apache config files dynamically or build them into an AMI?
A: Difficult to answer without more information. There are pros and cons to AMIs. If it's simple and quick to create/modify the files on launch, then I'd do it that way.
DevOps is a big subject and there are many options available to you for bootstrapping EC2 instances. Pre-baked AMIs is one option. Another simple option that you might consider is to write userdata scripts, that run at launch time, and that set up the instance for you (see simple nginx example). They can install software, modify config files, start services, and other things. They can also pull collateral such as pre-staged config files from S3, which can be a handy option.
Related
I have no trouble reading files of different types using GDAL's Java bindings (version 2.2.1) via the org.gdal.ogr.ogr.OpenShared(filePath) method to create a DataSource. If I want to create a SQLite file from a DataSource, however, how would I do it?
Looking in the JavaDocs, I've found some ExportTo methods on the Geometry object that you can use to manually build GeoJSON, WKT, KML and others: http://gdal.org/java/org/gdal/ogr/Geometry.html
There doesn't seem to be anything in the Driver class that would let you use them to export a DataSource however.
Using ogr2ogr it would be as simple as running the following:
ogr2ogr -f "SQLite" ./output.sqlite3 ./input.geojson
And there is this technique for running ogr2ogr from within Java, but I would have assumed there'd be something native in the Java bindings.
I've accepted that the best way to do this is to simply include the ogr2ogr.java file from the GitHub repo in my project and wrap it in a function that makes it cleaner to access. It is almost a direct port of the original C++ GDAL file.
The one change I made was to rename the ogr2ogr main function to execute so that it didn't confuse application when I ran it.
I need to parse the configurations defined in a Vagrantfile written in Ruby and use the settings elsewhere in my java code. Tried exploring jRubyParser but din't come across any documentation that defines it's use.
Cloned the Vagrant repo locally, but browsing through the code does not help either as I don't have prior experience with Ruby. How would Vagrant be reading the configurations defined in the file ? Any inputs ?
Vagrantfile is a regular Ruby script, i.e. it's meant to be interpreted by Ruby intepreter more than read as a configuration file.
To make things harder, some configuration options aren't declared as top level variables in Vagrantfile, but rather as properties of object in some function calls (like "config.vm.provider".
Depending on how complex your configuration is, I would consider just reading the file line by line and do regular expression matching to get variables I'd need. Not the most elegant solution, but probably way quicker too implement than alternatives.
Also, if your provider is always the same, say VirtualBox, maybe you could get some of your configuration from there. In that case, you would just need to read file located somewhere in "VirtualBox VMs" directory (on Mac, it's in "$HOME/VirtualBox VMs"). It's an XML file, so you could use one of the Java XML parsers to get what you need.
I am implementing a workflow of tasks in a Java program.
One of the tasks is running some commands on multiple Linux servers.
The servers are determined dynamically - read from an XML file.
I examined Rundeck's API, but it seems that I have to configure the servers in advance, which doesn't suit my needs.
Any ideas?
One answer is to use rundeck, I think you just need rundeck to dynamically load your nodes.
To make it dynamic you need to refresh the project. Simply restart rundeck or use the api refresh method. I haven't tried the latter which I think is the better solution. The Resource Model supports files and getting your node list of servers from an external source URL.
But if your are rolling your own a better answer maybe SSH and consider a SSH library for Java
If you consider using an external API look into using JSCAPE's SSH Factory for Java. Documentation can be located here.
I have no idea about converting EAR file into exe(Executable file), Where are i am working with jboss and i developing webservices. I want to give my product as executable file . Can anybody has idea about this.
Thank you
Gobi, you've already posted a question regarding this on 15th March, to which you've got no response. I guess you've just rephrased that same question here.
Might I suggest asking your customer/client how she would like the web service 'ear' delivered? I'm also guessing you might have database scripts, properties/config files etc. I'd put my money on 'a zip containing the ear, database scripts (if any) with related documentation'
There is no way a customer would want to 'double click' your ear and have it installed directly onto a server. If you read your Java EE spec correctly, you'd find a 'deployer' role in there. Its not there for fun. Its a very serious role whose responsibilities include 'configuring' your application.
Think about it.
You mean you want customers/users/whatever to just be able to double-click on your file, and there's a web server up and running? While that would be possible, it's not really the way most people want to run web services. They're very likely to want to run your web service within an existing container, configuring it alongside other services.
An EAR file is already designed to be pretty much droppable within a container, so that's fine. You could also supply a zip file (or an installer) with a sample container setup using any of the free container implementations - either preconfigured with some reasonable default values (e.g. for the port) or running through an installer wizard. I wouldn't spend too much time on it though - I'd assume that most people who want to run a web service will already have some experience of setting up a container, or will have specific requirements you couldn't easily capture in a wizard without a lot of work.
I don't know about making EAR as executable.
There is a editor which converts your project into setup file or installer for windows .
Hope this helps.
I used NSIS editor and recommend it and it only creates installer for windows.
HM NSIS Editor.
you may also have look at izpack
I just got a requirement to create a small (I assume standalone) utility to hit some code in our web application to do some custom processing of files from the app and then dump the files into a shared drive. My question is what is the best way for doing this? Do I just create a small app and then jar it up and run it off a command line or is there a better way?
Sorry, I didn't give enough detail. It's an old application, like over 10 years, so while it's been upgraded to jdk 1.6, most of the code uses the old collections, old loops, etc... There aren't any interfaces, very tightly coupled code that uses inheritance with lots of nested objects. The web app will do the processing. I think what they want is create some code outside of the application code that will login and then fire off the file processing code. Prior to this I had upgraded their version of Windward Reports in a separate branch and they want to make sure that the processed files: contracts, forms, etc.. don't get altered greatly as there are legal requirements on fonts and layouts. So this utility will go in, fire off the list of reports (a few thousand) dump it to a share drive so they can view them with another tool for comparision based on rules you can automate with that commercial tool, en masse. I was thinking create a small class with a main method, then jar it up and while the web server is running with my upgraded branch code, run the utility off the command line to fire it off.
There's not enough to go on here. How is the web app's functions exposed? If it's a REST interface then wget/curl/spring-rest-template are the way to go. If it's something like a JFS app then you're going to need something like Selenium to imitate a browser. If the functionality is in a shared library (JAR) then there web never even comes into play.
Well, I was originally looking at creating a standalone utility jar that I would run off the command line to connect with URLConnection to the app, but I found there is already testing code built into the application that I can run from a command line as long as I deploy the new code with the existing code. The utility will dump out the files to a shared drive and then XTest can be run to compare files. After reviewing the capabilities of XTest, it appears that it can handle the comparison of files well.