# daemontools: using java command&output as a service



## vecihi (Feb 12, 2013)

Hello, 

I'm using daemontools-0.76_16 on FreeBSD 8.2 release system.
If I try to manage a test.sh script with daemontools (*svc -d custommapp | svc -u customapp*), It is working correctly. But if I use "java command" shown as below, when send terminate signal with *svc -d customapp* java application (service: customapp) continuous to work. So with *svc -u customapp* java application is running correctly but *svc -d customapp* command is not working for *exec java ...* command. 


/var/service/customapp/run:  (start (svc -u) working, stop (svc -d) not working)

```
#!/bin/sh
exec java -cp "/opt/hercules/service/customapp/lib/*" -Xmx512m -DpropertiesConfigs=classpath:system/cmd.properties -Dhercules.jetty.port=1112 -Dimc.db.password=asdtest
```


/var/service/customapp/log/run:

```
#!/bin/sh
     exec multilog t ./main
```

/var/service/customapp2/run:  (start (svc -u) working, stop (svc -d) working)

```
#!/bin/sh
exec /tmp/test2.sh
```

/tmp/test2.sh:

```
#!/usr/local/bin/bash
echo "Sleeping 1000 seconds..."
sleep 1000
```

/var/service/customapp2/log/run:

```
#!/bin/sh
     exec multilog t ./main
```


Questions)

1)  Why I can't stop java application with *svc -d customapp*? (I guess run script's java call creates another process that can't be control by daemontools) How can fix it?


2) I want to log java command output with daemontools's logging mechanism for auto log rotation do I need any extra configuration?


----------



## SirDice (Feb 12, 2013)

vecihi said:
			
		

> I'm using daemontools-0.76_16 on FreeBSD 8.2 release system.


Please upgrade to 8.3, 8.2 has been end-of-life since July 2012.


----------



## vecihi (Feb 12, 2013)

I got the same result on FreeBSD 8.3, too




			
				SirDice said:
			
		

> Please upgrade to 8.3, 8.2 has been end-of-life since July 2012.


----------



## vecihi (Feb 12, 2013)

Solved:

Problem was releated with java command arguments... With correct parameters terminate job worked correctly

Thanks


----------

