# Starting Resin (App Sever) service at boot



## jigzat (Sep 22, 2011)

Hello everyone. This is my first post. I have to say that I'm new to FreeBSD. I have always admire FreeBSD philosophy more than GNU/Linux but I never had the chance to actually test it deeply. Right now I'm running Resin from Ubuntu server but I wanted to give FreeBSD a chance. So far so good. I manage to install and run Resin but I have no idea how to start the service at boot. I know that BSD and GNU/Linux use different init systems but apart from that fact I don't know how to do it on FreeBSD. Is the GNU/Linux resin.sh compatible with FreeBSD?


----------



## wblock@ (Sep 22, 2011)

Ports usually install start/stop scripts in /usr/local/etc/rc.d.  Enabling these scripts is done in /etc/rc.conf.  For example, enabling Apache22:

```
apache22_enable="YES"
```


----------



## DutchDaemon (Sep 22, 2011)

According to the port's pkg-plist it installs 
	
	



```
etc/rc.d/%%APP_NAME%%.sh
```
 which whould translate to /usr/local/etc/rc.d/resin($version).sh. In there you should be able to see what it expects in /etc/rc.conf to get auto-started (if that's possible), but it should indeed be something like 
	
	



```
resin($version)_enable="YES"
```
 in a typical case.

($version alludes to www/resin2 or www/resin3)


----------



## jigzat (Sep 22, 2011)

Thank you both for your answers. I can confirm that resin.sh works if I manually execute *./resin.sh* works but it doesn't work at boot I keep getting an exe: java: not found error although I set JAVA_HOME and PATH variables.

I don't think the version name matters since the start up script is named resin.sh.


----------



## jigzat (Sep 22, 2011)

It looks like I'm gonna make it! For some reason I had to manually set JAVA_HOME and RESIN_HOME on the resin.sh script itself. I don't know why but it seems it is going to work except for the fact that is looking for the resin.xml conf file in the wrong place, but I think that fits more in the Resin forums.


----------



## jigzat (Sep 22, 2011)

Bad news. FreeBSD tries to start Resin but it fails. These are the facts.


I had to modify the script to include JAVA_HOME RESIN_HOME path although I already set those under /etc/profiles

The resin.sh script only gets called if I put it under /etc/rc.d and not in /usr/local/etc/rc.d

If I put it under /etc/rc.d tries to start but fails because it is passing the "faststart" parameter which resin doesn't  recognize


----------



## jigzat (Sep 23, 2011)

Ok, I finally made it run but I have some issues that are not related to Resin. For some reason /etc/profile JAVA_HOME doesn't get respected. It doesn't matter if I set it, *echo $JAVA_HOME* comes up empty under bash and under sh it says undefined variable, and I have to set it in the resin.sh script or exporting the variable manually each time I log in.

The other issue is relate to /usr/local/www. I am supposed to set the resin root-folder and back in GNUL I set it as /var/www, now in FreeBSD I am tempted to use the /usr/local/www that is already created and set the owner as the www user which according to the resin.sh file is the user that is supposed to start the service. Is this recommended?


----------

