Mac Server Service

I have modified servoy_server.sh to change to the application_server directory and the service now starts fine

#!/bin/sh
cd /Applications/Servoy_5/application_server/

while true
do
	java -Djava.awt.headless=true -Xmx256m -Xms64m -XX:MaxPermSize=128m -classpath .:lib/ohj-jewt.jar:lib/MRJAdapter.jar:lib/compat141.jar:lib/commons-codec.jar:lib/commons-httpclient.jar:lib/activation.jar:lib/antlr.jar:lib/commons-collections.jar:lib/commons-dbcp.jar:lib/commons-fileupload-1.2.1.jar:lib/commons-io-1.4.jar:lib/commons-logging.jar:lib/commons-pool.jar:lib/dom4j.jar:lib/help.jar:lib/jabsorb.jar:lib/hibernate3.jar:lib/j2db.jar:lib/j2dbdev.jar:lib/jdbc2_0-stdext.jar:lib/jmx.jar:lib/jndi.jar:lib/js.jar:lib/jta.jar:lib/BrowserLauncher2.jar:lib/jug.jar:lib/log4j.jar:lib/mail.jar:lib/ohj-jewt.jar:lib/oracle_ice.jar:lib/server-bootstrap.jar:lib/servlet-api.jar:lib/wicket-extentions.jar:lib/wicket.jar:lib/wicket-calendar.jar:lib/slf4j-api.jar:lib/slf4j-log4j.jar:lib/joda-time.jar:lib/rmitnl.jar:lib/networktnl.jar com.servoy.j2db.server.ApplicationServer "$@" 1>> server.log 2>> server.log
	EXITCODE=$?
	if [ "$EXITCODE" != 99 ]; then exit $EXITCODE; fi
done

With Servoy 3.5.x I have also had to add

sleep 30

to give PostgreSQL time to start up.

Hi,

I have also a servoy.plist script in //Library/LaunchDaemons, but the Servoy app server won’t start on Systemstart of Mac OSX. Here is the script:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>Disabled</key>
   <false/>
   <key>Label</key>
   <string>servoy server</string>
   <key>OnDemand</key>
   <false/>
   <key>ProgramArguments</key>
   <array>
      <string>/bin/sh</string>
      <string>/volumes/ServerOSX/Applications/Servoy522/application_server/servoy_server.sh</string>
   </array>
   <key>RunAtLoad</key>
   <true/>
   <key>ServiceDescription</key>
   <string>launch item of the servoy server</string>
</dict>
</plist>

Is there anything wrong?
I also tried to modify the servoy_server.sh like:

#!/bin/sh
cd /Applications/Servoy522/application_server

while true
do .......

But this is also not working.

Thanks in advance for little help

Hi Thomas,

a couple of things to try:-

  1. does the servoy_server.sh script start the server correctly if you run it manually in the terminal?
  2. If it runs, try manually starting the launchd script in the terminal. Look at

http://diymacserver.com/installing-apac … n-leopard/

for an example of what you need to do.

Hope this helps,

Hi Christian,

you could help a lot. Thank you.

swingman:

  1. does the servoy_server.sh script start the server correctly if you run it manually in the terminal?

The script starts the servoy app server correctly!

swingman:
2. If it runs, try manually starting the launchd script in the terminal.

At first I had a mistake, because I took the .plist file into the /Library/LaunchDaemons directory (the postgresql .plist is there). Now I have moved the servoy.plist file to /System/Library/LaunchDeamons and it is starting the servoy app server by launchctl load in the terminal! But only by normal admin rights and not as sudo and/or su.
The problem should be the permission setting of the .plist file. All other files in the directory are set to “system = rw, everyone = r, …”. The servoy.plist file’s setting is “admin = rw, everyone = r”. How can I change to the right working permissions of the file because the servoy app server doesn’t start on a restart of the Mac?

Regards,
Thomas

Hi Thomas,

Your plist has a parameter called ‘Label’ which should be (usually) the same name as the plist file.
Here is my plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>   
	<key>Disabled</key>
	<false/>
	<key>Label</key>
	<string>com.servoy.server</string>
	<key>GroupName</key>
	<string>admin</string>
	<key>UserName</key>
	<string>admin</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Applications/Servoy/application_server/servoy_server.sh</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>WorkingDirectory</key>
	<string>/Applications/Servoy/</string>
</dict>
</plist>

So in my case the file is named “com.servoy.server.plist”.
I also added the (system) username and (system) groupname under which Servoy server should be running.

You need to change the owner of the .plist to root:wheel.

sudo chown root:wheel /Library/LaunchDaemons/com.servoy.server.plist

Now you need to load the plist into launchd.

sudo launchctl load /Library/LaunchDaemons/com.servoy.server.plist

This will actually start the server and will launch it also on a restart of the machine.

Now it’s loaded into launchd you can use launchctl to stop, start or unload the plist by it’s label (com.servoy.server).

Hope this helps.

Hi Robert,

thank you! I got it to work now!

Thomas