I've created a .jar file which listens on port 8089 and receives post requests. I start it in the background on my linux machine with the following commands:

nohup java -jar myServer.jar &
[1] 19769
-bash-4.1$ nohup: ignoring input and appending output to `nohup.out'
[1]+  Running                 nohup java -jar myServer.jar &

It may be redundant to use both nohup and disown, but my understanding is that this should work effectively to run the process in the background and detach it from the terminal. When I log out of my SSH and log back in, it is still listening:

tcp    0    0*       LISTEN      19769/java

Now I log out and attempt to send a post request. I receive a no response error, and when I log back in, the process is not running anymore. Somehow sending the post request while not logged in causes the process to crash. What have I missed?

Edit: in response to the first comment by @vastlysuperiorman, it should be noted that my nohup.out file does not contain any errors, and that when I launch a post request from curl while logged into the server, it returns the data as expected.

  • 1
    I suspect that this has nothing to do with whether or not you're logged in. More likely, the code is having a fatal error upon receiving the POST. Have you looked at nohup.out to see if the application logged any errors? Have you tried sending the POST with curl while still logged into the box? If you can update your question with the results of those actions, it might help us answer. – vastlysuperiorman Nov 16 '18 at 22:10
  • @vastlysuperiorman thanks for the helpful questions. I've edited my question with what I've observed. Note that it is only when I run a post request while logged out that I experience the error, when logged in it works fine until I run one when I'm logged out. – hayfreed Nov 16 '18 at 22:50
  • systemd killing user processes on logout? – roaima Nov 16 '18 at 22:53
  • @roaima don't think so. As noted above, if I log out and log back in the process still runs. It is only when I launch a post request to the server while logged out that the process stops. – hayfreed Nov 16 '18 at 22:57
  • 2
    Thanks for updating your question. If strace isn't available, do you have the ability to modify the code? Can trace logging be enabled, and can you add more log messages in the application itself? As far as I can tell, you're properly backgrounding the application. The fact it's still running after you disconnect your session is evidence of that. Unless there's a significant difference in the requests themselves or the way the application responds to loopback, the problem isn't likely to be at the OS level. – vastlysuperiorman Nov 17 '18 at 2:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.