I have a few Java applications, mostly with Spring Boot, in different servers (Droplets) from Digital Ocean. Previously I upload each new release manually and with some shell scripts created I am able to start/stop the applications. These scripts contains environment variables when it's necessary for test or production environments. To check if the application is running I have a cronjob launched every 5 minutes, this cronjob execute a shell script to start the application if it's not running.
However I switched to automatic deployments using Bitbucket pipelines and now I won't have shell scripts anymore because all the configuration will provided by the Bitbucket pipeline and will be executed over SSH.
For instance cat environment.sh start.sh | ssh xxx#yyy where environment.sh is created on the fly by the pipeline with right configuration in that moment for each environment.
How can I do something to start the application automatically if it's not running? Should I upload the script files in each automatic deployment and use a cronjob?
You should use a wrapper. YAJSW is popular, free and works (in my experience) well in production systems. The wrapper will restart your process if it crashes and can easily be installed as a service over many different OSes without much effort.
NOTE: I am not affiliated or related in any way to YAJSW.
Related
I have a Linux (CentOS) based development system that is running Docker, and I have several other machines that will be used to develop client and server- side software that will be run in a Docker container. All software will be developed using Eclipse.
I have learned how to access and run remote docker containers from within Eclipse. What I would like to do is set up an environment where developers can write code (for example, server side code) in any language supported by Eclipse (particularly Java or Typescript), compile that code and run/debug it using Eclipse's debugger but within a remote docker container.
I have seen this capability in another IDE. VSCode has that capability for developers writing Python- based microservices. It allowed a team I was working with to write microservice code from within VSCode and actually run debugging sessions using VSCode debugger within a remote Docker container that was running on a shared, secure VM!
Is there a way to do this using Eclipse? If so, how can it be done?
So I'm really new to the Java webstack world, and had a question on the most efficient solution to my problem. Some background information first; I'm running Tomcat on a Lubuntu 14.04 server listening on Port 80, developing on a separate Windows computer in Spring Tool Suite (developing Spring applications obviously). Currently, whenever I want to test something, I...
1) Export the project as a WAR file from Spring Tool Suite
2) Undeploy the old WAR file from the server from the Tomcat manager webapp
3) Deploy the new WAR file that I just got from Spring Tool Suite (which takes ~15 seconds)
Is there any faster way to do this? Normally, I wouldn't be opposed to just developing on localhost. However, I'm going to be doing a group project, so we would all need access to the same SQL server, which would be the one hosted on the Lubuntu 14.04 server.
How can I solve this issue?
Most IDEs have the ability to deploy to server for both development and production purposes.
Those that don't have this ability inbuilt, ususally have a add-on that enables this.
You can also use build tools such as maven or gradle to undertake these actions.
Since you raised a good point of working with others it is important that all are across the deployment process and that the process is standardised to ensure no weird issues/bugs pop up.
I'm new to Java and Java web applications. I'm trying to understand why I should use a Java application server like Tomcat instead of running it from command line.
Should I running Jenkins without a servlet container in production i.e using java -jar jenkins.war?
Is Tomcat more suitable for production environments?
Are there other advantages?
Please give me some idea why running the application in a servlet container is important.
Actually when you run Jenkins as "java -jar jenkins.war" it starts embedded servlet container anyway (Winstone or Jetty). Since main load on build server comes not from web users, but (surprise-surprise) from build jobs, I don't think servlet container type can affect performance. Moreover build jobs are started in separate JVM or even on slave machines.
Also all server/job/plugins configuration is stored in Jenkins home / config folder, so the way you started Jenkins does not affect server maintenance / backup tasks. Native installers also create user and start Jenkins as a service.
"Jenkins: The Definitive Guide" - "Running Jenkins as a stand-alone application may not be to everyone’s taste. For a production server, you might want to take advantage of the more sophisticated monitoring and administration features of a full blown Java application server such as JBoss, GlassFish, or WebSphere Application Server. And system administrators may be wary of the relatively little-known Winstone server, or may simply prefer Jenkins to fit into a known pattern of Java web application development. If this is the case, you may prefer to, or be obliged to, deploy Jenkins as a standard Java web application."
I'm relatively unexperienced in developing JAVA and I was hoping on getting some advice.
I have a modular JAVA server application setup in which a high level service that acts as a front-end interface which communicates with 8 lower level services.
In production, each service is hosted on its own machine.
I'm looking to profile a standard SE development environment which launches all instances locally. I am currently using eclipse and JVMmonitor.
My current workflow involves manually starting each service, followed by triggering the monitoring process on each service manually through eclipse. This workflow gets the job done, but I'm sure there is a more intelligent solution someone has come across. Most forum postings only solve monitoring one java instance.
Are there any other stand alone JAVA applications that anyone would suggest? I would like to avoid adding profiling code if possible.
Most profilers allow you to profile JVMs without the need to manually start the profiler.
For example, JProfiler calls this "offline profiling" and the integration wizards in the JProfiler GUI have an option for it:
Disclaimer: My company develops JProfiler.
Use visualVM.You can profile from urs local computer to different servers .
http://docs.oracle.com/javase/6/docs/technotes/guides/visualvm/applications_remote.html For profiling in different servers you need to define jstatd.all.policy file. For example if you want to monitor to different servers say s1,s2,s3 then in s1,s2,s3 server define jstatd.all.policy file and run statd - Virtual Machine jstat Daemon.Then from yours local computer you can monitor 3 s1,s2,s3 servers.
In very easy to configure it.
1.Run visualVm you can get eclipe pluging for it.
2.Run jstatd -J-Djava.security.policy=D:\jstatd.all.policy // location of yours jstatd.all.policy file in yours servers
3.In jstatd.all.policy define
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
4.Now connect to yours servers and monitor from local .
I need to call a jar which is kept on a shared windows machine.
The JVM also needs to be placed on this shared machine so that anyone with access to the remote location should be able to call this jar.
I need to write a windows script which shall be run using a service user.
Is this possible? If yes, request you to please provide pointers.
Java Management Extensions provides the tools for building Web-based, distributed, dynamic and modular solutions for managing and monitoring devices, applications, and service-driven networks.
see JMX Tutorial
see example with Linux script
see Windows cmd script
You might have some luck using the Tanuki Software Java Service Wrapper. Jetty uses this for their Windows Service Wrapper.
Another option is Apache Commons Procrun, which is what Apache Tomcat uses.
Both work well to set up a Java application as a Windows service. You will need to ensure your application is designed to run well as a service; you should be able to "trigger" events (start, stop, restart, etc.). You might need a lightweight adapter around the application to get it to work right as a service; but that should be a trivial exercise.
Once you have a service set up, make sure appropriate user(s) have rights to start/stop the service [1] [2]. You could even set the service up to run using a specific account. Then you can use the net start, net stop, etc. commands in a batch file.