I'm using prunsrv to create windows services. I would like to ask you if it is possible to query the status of a process (if it running, stopped) or if a process is existing. Also I would like to read the content of the pid file with a Java program.
1
There are 1 best solutions below
Related Questions in JAVA
- Add image to JCheckBoxMenuItem
- How to access invisible Unordered List element with Selenium WebDriver using Java
- Inheritance in Java, apparent type vs actual type
- Java catch the ball Game
- Access objects variable & method by name
- GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
- Perform a task each interval
- Compound classes stored in an array are not accessible in selenium java
- How to avoid concurrent access to a resource?
- Why does processing goes slower on implementing try catch block in java?
- Redirect inside java interceptor
- Push toolbar content below statusbar
- Animation in Java on top of JPanel
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- Java Assign a Value to an array cell
Related Questions in PROCRUN
- Run ActiveMQ as a 64-bit service on Windows Server 2008
- Can't deploy application as windows service from shortcut in Windows Server 2008 r2
- Jar file NOT running as windows service ( using Procrun )
- Making windows service from java class with additional libraries
- windows service access to network before logon
- apache daemon procrun- java app as windows service- failing to start in 64-bit windows 7
- Windows service installed with Procrun works in //TS mode, but doesn't start as a Windows service saying it "started and then stopped"
- Check service is running with procrun
- Configure procrun in Linux machine?
- Apache Tomcat 10.0 Silent Installation
- Java how to persist a process reference so I can run process.destroy()
- How do I setup a standalone java application to run as a service using procrun?
- apache procrun fails to start service
- Tomcat procrun installer does not work with spaces in path for catalina_home
- Java as windows service with Apache Procrun and --add-module --add-opens --add-exports
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Yes, with a trick: Create a local socket in the start up code of the service. If you get an error creating the socket, you'll know that an instance of the service is already running.
If you want to check that the service is alive, you can connect to the socket. If that fails, the process isn't there.
And you could return the PID of the service via this socket, so the "monitor" program wouldn't need to know the log path and PID file name. And if you implement the start/stop methods, you can even tell the monitor the status of your service.
The biggest advantage of this is that the OS will make sure that the socket is closed when your service terminates for any reason. The second advantage is that this works independent of the OS - if you ever need to move this to Linux or Mac, no changes to the code will be necessary.