Automate, Start & Stop a specific service instance in TIBCO administrator using java (backend) - tibco

Am new (and am from not IT background) to this TIBCO community and need your immediate help in finding out a quick resolution to my below requirement .
I need to automate Start and Stop activity on a specific service instance in TIBCO Administrator(TIBCO ActiveMatrix BusinessWorks 5.13.0) using java .kindly explain me in layman terms.
What all the information i need in order to perform this activity?
This is what i need to automate in TIBCO Adminstrator in backend.
a. start/stop Service instance
b. confirm if the service instance is started/stopped.
Thanks in advance.
TIBCO Version used:
TIBCO Administrator
Version Information
TIBCO Administrator: 5.10.0_V19
Tomcat: 7.0.62.0
TIBCO Repository: 5.10.0_V18
JRE: 1.8.0_191
TRA: 5.10.0_V19
TIBCO Rendezvous (RV): 8.4.5
TIBCO Hawk: 5.2.0.V21

You would need to find out if service is running or not on machine where it is deployed. normally you may use ps -eaf|grep then you will get the application.tra path with PID in it... it means your service is up and running..if now output is there then it means application/service is in stopped state.
though you may also create tibco hawk rule bases (tibco monitoring tool) for your application which will send you the alert if service would be in start/stop state.
Let me know if you need more help on it.
--Manoj

In order to start and stop, you can do this easily by using AppManage command.
Please refer to the documentation here, but here is the general syntax:
AppManage -start –domain <DomainName> -user admin -pw xxxxx -app "Folder/Path/to/App/Appname" -service "Process Archive.par" -binding "Process Archive
Some parameters are optional, again, please refer to the documentation for details.
As #Manoj pointed out, you need to know which applications are stopped before you can fire a start command. For that, you can do the ps -ef grep command in Unix.
In summary, you can achieve the entire thing using just Unix commands. All you have to do is call these Unix commands in your Java code and pass the relevant variables.
Steps:
ps -ef | grep appname
This will give you where the app is started or not (no result will means not started).
AppManage -start –domain <DomainName> -user admin -pw xxxxx -app "Folder/Path/to/App/Appname" -service "Process Archive.par" -binding "Process Archive
This will start the application.
AppManage -start –domain <DomainName> -user admin -pw xxxxx -app "Folder/Path/to/App/Appname" -service "Process Archive.par" -binding "Process Archive
This will stop the application.

Related

springboot project building non-stop server on AWS EC2

I made java springboot project for the first time. SO need some advice.
I used gradle, war.
I git-pushed my project on AWS EC2.
and run java -jar filename.war which succeeded data communication with frontend.
But when I leave the terminal with ctrl +c , the java server stops.
Which way is the best to build non-stop server like Node pm2?
In my EC2 virtual machine, there are several projects and I use NginX to route each projects to different port numbers.
Thanks in advance!
Linux
You can use nohup:
nohup java -jar -Djava.awt.headless=true your_server.war > /path/log.out &
Later you can use:
ps aux // to get the $PID of your process
kill -9 $PID // to kill the process
Windows
Please check this answer

Logging to Adobe CQ5 using PuTTY

I would like to learn about connecting to the CQ5 server using Putty SSH/telnet client for windows to perform operations like server start/stop, check status etc
I tried connecting, but got connection refused.
If anyone could help with the steps to connect, it would be useful.
Thanks,
Sriram
This is not CQ5 related!
If the server you are trying to connect to is not offering ssh access you won't be able to connect this way. Maybe you are trying to connect to a windows-server? Try remote-desktop in this case.
The below is the Example that might be useful when you are using a putty client from windows, and the CQ5 is hosted in the Linux box.
open the putty window, provide the details
1)HostName or (Ip Address)
Example: 192.168.1.1
2) Enable SSH radio button(which defaults to port 22)
then click on open which prompts you for the linux box username and
password.
Then navigate to the bin folder which is inside of your
crx-quickstart folder is located.
Example: Navigate to "/CQ5/Author/crx-quickstart/bin/"
Use "sh start" or "sh stop" commands to run start and stop scripts of the CQ. Some more info
You can list the process which are up and running on which address by " netstat -lnptu " command
Use " kill -15 PID " for killing a process with specific process id (Example : kill -15 5574)
Apache Felix provides a shell that allows you to interact with the OSGi framework and with shell extensions that CQ5 or applications that run on it can supply. Maybe that's what you're looking for.
Installing the org.apache.felix.shell, org.apache.felix.shell.remote and org.apache.felix.shell.tui bundles provides a remote shell that's accessible via telnet 6666 by default.
Adding the org.apache.felix.gogo.command, org.apache.felix.gogo.runtime and
org.apache.felix.gogo.shell bundles activates the richer Gogo shell.

How to stop/start specfic WebSphere-deployed EAR from command line?

I'm throwing a dependency jar into my exploded EAR on WebSphere app server. I need to stop/start the EAR to get WS to execute the new code. Is there a way to do this from command line?
Try running something like this:
/opt/ibm/websphere/appserver/profiles/<MyProfileName>/bin/wsadmin.sh -c "AdminControl.invoke(AdminControl.queryNames('type=ApplicationManager,process=<MyServerName>,*'),'stopApplication','MyAppName')" -lang jython
It will prompt you for a WAS Userid and password (in case you have enabled "Administrative Security") and when you enter them - provided your userid has at least been assigned the Operator Role - your application will be stopped.
In a similar way you may start the same application.
You should be able to manage that using the wsadmin command line tool provided as a part of your WAS installation. Pretty much any administration task can be scripted using this tool.
I don't know the specific command to do what you've asked but here is a link to the documentation that should help get you going.
http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Ftxml_script.html

Add nginx.exe as Windows system service (like Apache)?

I set up NGINX as a front end server for static content and I use Apache as a back-end server for other thing.
The thing is I can't find a logical answer that allows me to make nginx.exe a Windows system service (like my Apache).
Any come across an answer to this?
How to do it with Windows Service Wrapper
(Note: There are easier alternatives by now - see also solutions described here below using chocolatey package manager by suneg and using NSSM directly from Adamy)
Download the latest version of Windows Service Wrapper via github or nuget.
Current version as of this writing is v2.2.0
Since v2.x executables for .NET2.0 and .NET4.0 are available - others only on demand.
Rename winsw-*.exe to something like nginxservice.exe.
This is the name that will show up for the process that owns your nginx process.
Place an XML file next to the exe with the same base name, e.g. nginxservice.xml. The contents should be like below (verify your nginx location).
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<executable>c:\nginx\nginx.exe</executable>
<logpath>c:\nginx\</logpath>
<logmode>roll</logmode>
<depend></depend>
<startargument>-p</startargument>
<startargument>c:\nginx</startargument>
<stopexecutable>c:\nginx\nginx.exe</stopexecutable>
<stopargument>-p</stopargument>
<stopargument>c:\nginx</stopargument>
<stopargument>-s</stopargument>
<stopargument>stop</stopargument>
</service>
You can find up to date details about the configuration on the config github page, a generic example showing all possible options here and an installation guide.
Run the command nginxservice.exe install as administrator.
You will now have an nginx service in your Services! (It is set to start automatically on boot; if you want to start your server, you must manually start the service (net start nginx).)
Detailed description of correctly setting up nginx as a Windows Service:
http://web.archive.org/web/20150819035021/http://misterdai.yougeezer.co.uk/posts/2009/10/16/nginx-windows-service/
Additional info not contained in above blog post:
You can find the latest version of the Windows Service Wrapper also via this Maven Repository:
http://repo.jenkins-ci.org
Examples for Maven + Gradle:
<dependency>
<groupId>com.sun.winsw</groupId>
<artifactId>winsw</artifactId>
<version>2.2.0</version>
<classifier>bin</classifier>
<packaging>exe</packaging>
</dependency>
<repository>
<id>jenkinsci</id>
<name>jenkinsci-releases</name>
<url>http://repo.jenkins-ci.org/releases</url>
</repository>
compile "com.sun.winsw:winsw:2.2.0"
repositories {
mavenCentral()
maven { url http://repo.jenkins-ci.org/releases }
}
Download NSSM form
http://nssm.cc/download .
"Run %NSSM_HOME%\nssm.exe install “Nginx”"
Select the Nginx executable in the NSSM dialog, then OK.
Go to Services and start the new created service "Nginx", done.
You can using start.bat and stop.bat to realize the same effect.
start.bat
#ECHO OFF
REM Start Nginx
tasklist /FI "IMAGENAME eq nginx.exe" 2>NUL | find /I /N "nginx.exe">NUL
IF NOT "%ERRORLEVEL%"=="0" (
REM Nginx is NOT running, so start it
c:
cd \nginx
start nginx.exe
ECHO Nginx started.
) else (
ECHO Nginx is already running.
)
stop.bat
#ECHO OFF
REM Stop Nginx
tasklist /FI "IMAGENAME eq nginx.exe" 2>NUL | find /I /N "nginx.exe">NUL
IF "%ERRORLEVEL%"=="0" (
REM Nginx is currently running, so quit it
c:
cd \nginx
nginx.exe -s quit
ECHO Nginx quit issued.
) else (
ECHO Nginx is not currently running.
)
SC.EXE will only work for executables that already support the Windows Services API and can respond properly to start and stop requests from the Services Control Manager (SCM). Other regular applications, not specifically written as a service, will simply fail to start (usually with error 1053)...
For those exe's, you need a "service wrapper" -- a small utility that can accept the start/stop commands from the SCM and run/terminate your application accordingly. Microsoft provides Srvany (which is free yet very basic), but there are several other free and commercial alternatives.
BTW, you should check out this guide showing how to run Nginix as a service, especially step 7 which discusses how to stop Nginix properly. Not every wrapper will support that functionality (Srvany doesn't)...
The easiest way I've found, was using the Chocolatey package manager.
Once Chocolatey is installed, you open an administrative prompt and type:
choco install nginx
You now have a Windows service named 'nginx' running.
NSSM is the best tool to run Nginx as a service.
If you do not want to use any external 3rd party software then you can implement any of these two methods.
Windows Task Scheduler
Windows startup shortcut
Windows Task Scheduler
As mentioned in this answer prepare one start.bat file.
Put this file where nginx.exe is present.
Open windows task scheduler and set up the task as described in this answer to run it indefinitely.
Do not forget to run this task as the highest privilege with the system account, more details can be found here.
Make the task to start daily at a certain time, through the bat file it will check whether the service is already running to avoid creating multiple nginx.exe instances.
If due to some reason Nginx shuts down, within 5 minutes it will start.
Windows Startup shortcut
Create one shortcut of nginx.exe and put it in the startup folder of Windows.
Follow this answer to find your startup location.
Nginx will run automatically whenever you log in to the system.
This one is the easiest. However, it is dependent on user profile i.e. if you are running Nginx on a server, it will run only for your user account, when you log off it stops.
This is ideal for dev environment.
Download zip file from here.
Extract nginx-service.exe from winginx\build and run it.
Rather than turning nginx into a service, or using CMD to start a process, which really doesn't seem to work. I found that Powershell makes it easy to startup nginx as a detached process. I've combined starting nginx with PHP. Below is the script, named "start-nginx.ps1"
$fcgiPort = "127.0.0.1:9000"
$PHPini = "c:\php\php.ini"
$ErrorActionPreference = "SilentlyContinue"
function restart {
Push-Location /nginx
Stop-Process -Force -Name nginx
Start-Process ./nginx.exe -WindowStyle Hidden
Stop-Process -Force -Name php-cgi
Start-Process "c:\php\php-cgi.exe" -ArgumentList ("-b" + $fcgiPort + " -c " + $PHPini) -WindowStyle Hidden
Pop-Location
}
restart
This script can be executed from any directory, but needs to be customized for where your nginx installation is located.
This script includes a silent attempt to kill nginx and PHP before launching both.
Windows systems are supposed to recognize ".ps1" files as powershell, even in the CMD prompt.
I created another small script to kill the running processes, which simply removes the "start-process" lines from this file.
To run at startup, I used the win-R command to navigate to the directory shell:startup
Placing a shortcut to the startup script in this directory, nginx starts at boot!
Powershell also includes a much more sophisticated ability to schedule tasks, and it is possible to schedule this script to run at startup. See This Link
From the article:
>powershell
$trigger = New-JobTrigger -AtStartup -RandomDelay 00:00:30
Register-ScheduledJob -Trigger $trigger -FilePath $HOME/start-nginx.ps1 -Name startNginx
Combined, I think this approach gets you everything you'd need from an nginx windows service and doesn't require any third-party applications.
Official nginx wiki referes on winginx for this purpose. It builds exe-installer in linux environment.
Process looks like this:
sudo apt-get install nsis make
wget https://github.com/InvGate/winginx/archive/master.zip
unzip master.zip
cd winginx-master/
make
ls -lh ./build/nginx-service.exe
To get actual versions you should specify them in Makefile.

Jboss Service started and then stopped

I'm attempting to get my Jboss Server running as a windows service using the JbossService.exe, and I had it working until I uninstalled it (with ./JbossService -uninstall JbossService), and now, while it will install and the service will appear in the windows service list, attempting to start it will only yield the error message:
"The JBossService on Local Computer started and then stopped. Some services stop automatically if they have no work to do, for example, the Performance Logs and Alerts service."
If it helps, the command I'm using to install it is:
./JBossService.exe -install JBossService "$java_home\jre\bin\server\jvm.dll"
-Xmx128m -Xrs -Djava.class.path="$java_home\lib\tools.jar;$jboss_home\bin\run.jar"
-Duser.timezone="Australia/Sydney"
-start "org.jboss.Main" -stop "org.jboss.Main"
-method systemExit -out "$jboss_home\server\default\log\stdout.log"
-err "$jboss_home\server\default\log\stderr.log"
-current "$jboss_home\bin"
Any ideas would be appreciated. If more information is required just let me know.
Are you using Cygwin? If not, this could be due to the fact that environment variables are referenced using %%, not $, on Windows. You might try the following instead:
JBossService.exe -install JBossService "%java_home%\jre\bin\server\jvm.dll"
-Xmx128m -Xrs -Djava.class.path="%java_home%\lib\tools.jar;%jboss_home%\bin\run.jar"
-Duser.timezone="Australia/Sydney"
-start "org.jboss.Main" -stop "org.jboss.Main"
-method systemExit -out "%jboss_home%\server\default\log\stdout.log"
-err "%jboss_home%\server\default\log\stderr.log"
-current "%jboss_home%\bin"
Even if you are using Cygwin, the $ notation still might not work if, for example, these parameters are being stored in the Registry and then read later from the OS (which does not understand Cygwin notation).
While this does have a valid answer, one reason this happened to me recently is because the user the JBoss Windows Service was running as had certain active directory permissions revoked from the server (in this case, administrative-like permissions); it could no longer access certain directories it required in order to process (the Java bin folder, for example).
Once the user the service ran as was added back to the appropriate Windows User Groups, the JBoss Windows Service started with no issues.
In my case, JAVA_HOME was not set. Once I did that, Automatically windows Services started.
:)

Resources