0

I'm trying to make an web service which can also get commands via shell. So I want to make this app work like a daemon. So my question is how can I get arguments passed to shell while web service runs in the background? I can make script which starts this app as a daemon and give it a name but how can i get arguments in java passed later on?

EX. mydaemon add -stream somepage.com -channel channelName -start 2014-09-19 20:00:00 -end 2014-09-19 20:45:00

I can start a new thread in main method which gets system.in but will this get stuff sent to PID of my app. Btw, if this can make a change - I'm using Spring Boot in my app.

  • Are you asking about how to make runtime changes or just about how to read the command-line arguments from your Java program? – chrylis -cautiouslyoptimistic- Sep 20 '14 at 20:02
  • i know how to read command line arguments when starting the app but when i run it like daemon i have to send parameters to PID (i found scripts giving name to PID and then using java app as daemon) or something like that when app is already running and then read the input so i was wondering also can i make a new thread on app start and just read System.in - will this read commands sent with PID –  Sep 20 '14 at 20:14
  • "Sending parameters to PID" makes no sense. A PID is just a number identifying the process, and it there's no way to send information to it besides signals, which aren't what you want. If you're talking about trying to talk to the program while it's running, you're best off using a socket and communicating over that; a Spring MVC `RestController` is convenient for that. – chrylis -cautiouslyoptimistic- Sep 20 '14 at 20:18
  • i have to use shell input for this part and rest controller is already made it's just i need this part to http://stackoverflow.com/questions/11203483/run-a-java-application-as-a-service-on-linux has example script so i was wondering can i send some paramters to this process not the PID i've made a mistake when i said "send parameters to pid" –  Sep 20 '14 at 20:30
  • Why shell input? The whole point of a daemon is that it's running as a background process and isn't attached to a live tty. – chrylis -cautiouslyoptimistic- Sep 20 '14 at 21:12
  • well this daemon needs to process information sent by the client so it's not daemon it's rest running by itself(no third party webserver), now guy wanting this tool said ok thats complicated you can just make it accept commands trough url but anyway thanks for answering and i'm still wondering is it possible to make daemon run in bacground and then be able to send it some data to process Ex. while daemon runs in bacground open shell and write myapp -link somelink.com -time 12 maybe write one app as daemon and another as linux command which looks for daemon and sends info –  Sep 21 '14 at 17:20

0 Answers0