So now that we’ve managed to separate Apache from the runtime environment by using Nodejs, that means we were able to simplify the start and stops scripts directory to remove the scripts related to Apache. And now that we only need to start and stop Jaxer, that means it should be considerably easier to register Jaxer as a service to systemd. So after a little bit of trial and error we were able to get the service to work.
[Unit] Description=Jaxer Application Server After=network.target [Service] Type=simple Environment="LD_LIBRARY_PATH=/opt/AptanaJaxer/jaxer" Environment="JAXERBASE=/opt/AptanaJaxer" WorkingDirectory=/opt/AptanaJaxer/jaxer PIDFile=/var/run/jaxer.pid ExecStartPre=/opt/AptanaJaxer/jaxer/jaxer -reg -tempdir /tmp > /dev/null ExecStart=/opt/AptanaJaxer/jaxer/jaxermanager --configfile=/opt/AptanaJaxer/jaxer/config/JaxerManager.cfg ExecReload=/bin/kill -USR2 $MAINPID User=root Group=root [Install] WantedBy=multi-user.target
Our /etc/systemd/system/jaxer-server.service file is posted above. For now it looks like the process needs to run as root, but as we simplify more, we’ll try and define a user and group with only the permission we need. But for now it works, which means we can continue to simplify the runtime environment.
Even though we technically aren’t using the Apache version that we compile with Apatana Jaxer anymore, I think we might as well take the opportunity to write a systemd script for that as well. Right now the priority is to remove as many unnecessary files and folders as possible. And that allows us to have the Apache install as a backup, while also being able to remove the scripts folder. And if that works we’ll go ahead and remove the scripts folder from the install script in the repository in favor of only using scripts.
And a small note on the nodejs Apache-emulator script. We ran into an error almost immediately where the script wasn’t handling conditions when Jaxer wasn’t listening. So we added an error check when the connection is refused. We need to add another check for a connection timeout (right now the client hangs), but we’re still focused on simplification so we can comeback to that later when the issue comes up again.
Looks like I spoke too soon. The systemd installation didn’t work. I go t the wrong impression after executing /opt/AptanaJaxer/Apache22/bin/apachectl start and the process was already active in the background before starting from systemctl. As for systemd I tried several variations of executing with apachectl and httpd, but neither of them worked for reasons I was not able to track down.
I think it shows that we can still run /opt/AptanaJaxer/Apache22/bin/apachectl start to debug with apache if needed, though it’s not as graceful of an option as I would like. I might take a small detour to try connecting vanilla Apache from apt-get to see if I can get it working now that I have a better idea of how the environment variables are handled. Though in general I find Apache hard to work with, so we’ll have to see how that goes.