Payara Server Start as a service - glassfish

I want payara server to run as a service. I logged to asadmin as sudo and used the create-service command. The following output is given.
The Service was created successfully. Here are the details:
Name of the service:production
Type of the service:Domain
Configuration location of the service:/etc/init.d/payara_production
User account that will run the service: root
You have created the service but you need to start it yourself. Here are the most typical Linux commands of interest:
* /etc/init.d/payara_production start
* /etc/init.d/payara_production stop
* /etc/init.d/payara_production restart
For your convenience this message has also been saved to this file:
/home/buddhika/payara/glassfish/domains/production/PlatformServices.log
Command create-service executed successfully.
This create payara_production script in the /etc/init.d/ folder, yet once the computer is restarted, this script is not executed. I have to manually start payara to run it.
What does it mean by "You have created the service but you need to start it yourself", I had no similar issue with the versions of GlassFish I used earlier.
How can I start Payara as a service?

Payara Server (and also GlassFish) create a service using the System V mechanism. This mechanism is outdated and not well supported by newer Linux systems. Most modern Linux distributions use SystemD, which supports starting/stopping System V services using the system command but not directly enabling them at boot without any modification.
Your Linux distribution most probably uses SystemD. To run a service at boot time, you can follow this guide: https://linoxide.com/linux-how-to/enable-disable-services-ubuntu-systemd-upstart/. If you by any chance have access to Payara Support portal, you can follow this detailed guide: https://support.payara.fish/hc/en-gb/articles/360034527494-Configure-a-Payara-Server-Domain-as-a-System-Service
In short, you need to create a service file in /etc/systemd/system/ or any other folder where SystemD expects it. This file should contain ExecStart instruction to start the service, in your case /etc/init.d/payara_production start. If you want that it starts at boot also after a crash, add the `Restart=always" instruction.
If your service file is named payara.service, you can enable the service at boot with:
sudo systemctl enable payara
Edit:
Alternatively, you can run the service created by Payara Server at boot using SystemD if you modify the script to add some headers in a comment, as described here: https://serverfault.com/questions/849507/systemctl-doesnt-recognize-my-service-default-start-contains-no-runlevels-abo
For example, add this comment right below the #!/bin/sh line:
### BEGIN INIT INFO
# Provides: payara_production
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: your description here
### END INIT INFO
And then you can install it using the SystemD command:
systemctl enable payara_production.service

Related

How to setting RabbitMQ?

I just install RabbitMQ in my computer and want to run demo for sending message but it doesn't work. According to documentation the reason may because the broker was started without enough free disk space. And when I check RabbitMQ Management Dashboard, it show my free disk space only 46kb (by default it needs at least 200 MB free). According to documentation I need to change disk_free_limit.
From this documentation I have to create configuration file by myself and put it in C:\Users\User\AppData\Roaming\RabbitMQ. The documentation give an example script for configuration. I change the setting for disk_free_limit.absolute, restart computer (I don't know how to restart RabbitMQ service in windows). But when I check the RabbitMQ Management Dashboard the disk space still 46kb.
I highly recommend the usage of containers for running services like RabbitMQ to avoid problems like the ones you are having at the moment.
I usually use this dockerfile
FROM rabbitmq:3-management
RUN echo '[rabbitmq_management,rabbitmq_management_visualiser,rabbitmq_amqp1_0].' > enabled_plugins
RUN rabbitmq-plugins enable rabbitmq_amqp1_0
For running it
docker build -t my-rabbit .
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 my-rabbit:latest
If you never played with docker before, please read this.

How to check the if config command name is changed in AWS Elasticache(REDIS)

I am trying to access AWS elasticache(REDIS). I followed this instruction:
https://redsmin.uservoice.com/knowledgebase/articles/734646-amazon-elasticache-and-redsmin
Redis is connected now but when I click on configuration. I got this error:
"Redsmin can't load the configuration. Check with your provider that you have access to the configuration command."
edit 1:
config Redis command is sadly not available on AWS Elasticache, see their documentation:
https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/RestrictedCommands.html
To deliver a managed service experience, ElastiCache restricts access to certain cache engine-specific commands that require advanced privileges. For cache clusters running Redis, the following commands are unavailable:
[...]
config
That's why Redsmin configuration module (it's the only module impacted) cannot display current your Redis AWS Elasticache configuration.

Unable to connect to local RabbitMQ on Windows 10

I've installed RabbitMQ (latest version downloadable from RabbitMQ website) on my Windows 10 machine. It installed with ERlang 19.1.
I'm trying to install RabbitMQ Web UI Management Tools using the following command (using RabbitMQ Command Prompt):
rabbitmq-plugins enable rabbitmq_management
I'm getting the following error:
The directory name is invalid.
The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
Plugin configuration unchanged.
Applying plugin configuration to rabbit#[0x7FF9A8527044]... failed.
* Could not contact node rabbit#[0x7FF9A8527044].
Changes will take effect at broker restart.
* Options: --online - fail if broker cannot be contacted.
--offline - do not try to contact broker.
I've looked up on SO and tried stopping and restarting, overriding erlang cookie, but nothing helps.
I think there's a problem with RabbitMQ itself. The service itself is marked as started, but if I try to telnet the default port (5672) then it fails (it's not a firewall issue - I've disabled it).
Also I don't see an log files created for RabbitMQ or any related Event Logs messages. So it's hard to diagnose exactly the problem.
I also tried uninstalling and re-install both erlang and RabbitMQ. Still didn't help.
How do I further diagnose the problem?
Found a solution to the problem (downgrading Erlang did not work in my case, but just in case I left it on Erlang 18 in case there were other issues with ver 19).
What puzzled my eye was this line: Applying plugin configuration to rabbit#[0x7FF9A8527044]... failed.. Seems like it's trying to connect to rabbit instance at a wrong machine name.
I then ran rabbitmqctl.bat status which failed but again showed that it's trying to connect to [0x7FF9A8527044] while the node name was rabbit#my-mchine-name. So I started reading the configuration section at RabbitMQ website and the solution was simple - setting the node name manually.
All I had to do is add an environment variable named RABBITMQ_NODENAME with the node name being rabbit#localhost. And that's it. Problem solved!
you may be running into issues with Erlang 19 incompatibility. there has been some history of Erlang 19 support problems with RMQ. Try installing Erlang 18 instead.
If that fails, I would recommend using Docker for Windows and installing / running RabbitMQ in that. I've moved all my services like RabbitMQ, MongoDB, etc. into Docker containers and it's made my life as a dev so much simpler.
In my case I had to trash the local account config located at : %APPDATA%\RabbitMQ\.
Deleting the entire folder and reinstalling the service did the trick.
Rabbitmq 3.6.14
Erlang 20.1 OTP

Remotely start stop jboss server

I have a requirement to write a java program to remotely start stop a jboss server on request. Can anyone please suggest how could it be done? One option could be invoke start/stop script but this java program(may be servlet or jsp) exists on different machine. We are using jboss server 7.
A simple method to start and stopping Jboss remotely can be done with the run.sh and shutdown.sh script, by pointing to the right host and port. If you are on Linux you can run:
rsh user#host /path/to/jboss/bin/run.sh
rsh user#host /path/to/jboss/bin/shutdown.sh
You can also execute a Shell command with Java, you can use Runtime exec mewthod:
Runtime.getRuntime().exec("shell command here");
See this complete answer for more details on Java exec method.
A better alternative I would suggest, is to use JMX-console programmatically, you can stop/restart a Jboss intance by invoking the shutdown method on the Server MBean. JMX approach is more powerful because you can monitor and manage every aspect of the Jboss runinng instanace (like logging, memory or cpu). See this to start.
I've created a snippet to ease your start, see this working solution http://snipt.org/Ahhjh4
Remember:
create a Jboss user on the Jboss instance using add-user.sh (JBOSS_HOME/bin)
include the jboss-client.jar in your client class-path (the jar is in JBOSS_HOME/bin/client)
Good luck!

How to swap a server in and Out of cluster during runtime

I am implementing session replication in my application. This is old application.
I made all changes and now need to test the server switch and confirm that the objects in session is properly carried to another server in server list.
I have 1 Admin server and 2 managed servers. So the cluster is made of 2 managed server.
while testing I have to always bounce the server and test the flow of my application. This process is very time consuming. So I am looking for any other way to sway a server in and out of cluster
during runtime. I asked on Oracle support website , but they said only way to bounce the server.
How can I write a script for this?
Is there a parameter in weblogic or wlproxy plugin config file that help in this switch.
Your help is appreciated.
using Weblogic scripting tool (WLST) in script mode, you can write a script to automate the shutdown / startup of the managed server that you would like to remove temporarily from the cluster.
you create a file with .py extension which will contain the weblogic commands that you would like to run.
shutdown.py:
connect('username','password','t3://adminIP:port')
shutdown('servername')
disconnect()
startup.py:
connect('username','password','t3://adminIP:port')
start('servername')
disconnect()
to run the script from commandline:
java weblogic.WLST c:\myscripts\shutdown.py
you can put this line in a shell/batch script.
Another way is to write a Java program or an ANT script to invoke the commands using the weblogic.jar file that comes with weblogic.
If you were to change the state of a weblogic managed server from running to admin mode then also you can test the session replication.
You can do this from admin console by selecting the managed server and going to control tab and changing the state of the server to Admin. You can change it back to running from the same place.
Using WLST you can use the commands suspend and resume
http://docs.oracle.com/cd/E11035_01/wls100/server_start/server_life.html
http://docs.oracle.com/cd/E14571_01/web.1111/e13813/quick_ref.htm
suspending and resuming managed servers is quicker than shutting it down and restarting it again.
I have tested this at my end and it works fine, ie when I change the state to admin, my request goes to another managed server and the session is also replicated.
I have used the sample WLS cluster replication example available in wls installation.