Moving Run-time Location /etc/emrajs

We’ve been simplifying the post-install Jaxer environment one folder at a time. With the previous update we were able to get Jaxer working with Vanilla (apt-get) Apache. Which means that the only folder left in the post install directory is the jaxer folder which contains the binaries. Which means if we can move that folder to something like /etc/emrajs we would have something that starts to look like an actual Linux installation. But since we haven’t even looked into /usr/sbin or anything, so maybe let’s not get ahead of ourselves on that one.

So first step is we simply copy the working jaxer folder to the /etc/emrajs location.

# cp -r /opt/AptanaJaxer/jaxer /etc/emrajs

And now that we are working with vanilla Apache, it means we only need one service to start the Jaxer Manager application. We can copy and edit our original jaxer-server.service file, and we end up with something like this:

Description=Emrajs Application Server

ExecStartPre=/etc/emrajs/jaxer -reg -tempdir /tmp > /dev/null
ExecStart=/etc/emrajs/jaxermanager --configfile=/etc/emrajs/config/JaxerManager.cfg
ExecReload=/bin/kill -USR2 $MAINPID


And then we can save that as /etc/systemd/system/emrajs.service. And then try to start the service.

# systemctl start emrajs.service

And surprisingly the service seems to work with just changing the paths. So the other step is we need to make sure Apache can communicate with our newly installed folder. So we need to edit the envvars, and jaxer.http.conf file.

#if test "x$LD_LIBRARY_PATH" != "x" ; then
#  LD_LIBRARY_PATH="/opt/AptanaJaxer/Apache22/lib:$LD_LIBRARY_PATH"
#  LD_LIBRARY_PATH="/opt/AptanaJaxer/Apache22/lib"

export JAXERBASE=/etc/emrajs
export ANCHOR=/etc/emrajs

So for the /etc/apache2/envvars file I was worried about the LD_LIBRARY_PATH, but it looks like the folder it’s referencing doesn’t even exist in the original environment, so it looks like we can safely comment these two out. The only other change was to change the variables for JAXERBASE and ANCHOR.

And then the only other change we need to make are the paths referenced in /etc/apache2/mods-available/jaxer.httpd.conf. Which there are only three lines that need to be fixed:

LoadModule jaxer_module "${ANCHOR}/connectors/"

        # Configure the client framework file availablitly
        <Directory "${ANCHOR}/framework">
                Deny from all
                <Files clientFramework*.js>
                        Allow from all

Alias /jaxer/framework/clientFramework.js "${JAXERBASE}/framework/clientFramework.js"

Basically we’ve truncated the jaxer path from the full base location. We restart Apache2 and surprisingly it works. So last step is we removed the install directory as to make sure it wasn’t being referenced for something, and after restarting the services it looks like they still work.

Now seems like a good opportunity to go back and revisit the install script. Before I had three scripts, to make sure that they work. One to compile and install Apache, one to configure and install Jaxer, and then one to finalize the install. I think what I might do is concatenate all of these into one file to have one script that I can curl and execute. That way I can start from a fresh Raspberry Pi install, test the setup, and then be able to flash and reset the SD card for more testing if needed.

As for approach since we’re using Vanilla Apache, that means we can work towards removing the step of having to compile Apache. The main reason that step is included is for the purposes of the apr-util library, which we could potentially get via apt-get. There’s also something that get’s included from the Apache install directory when mod-jaxer get’s compiled, so I think it’s a viable option to remove a separate Apache compile during install, but we don’t need to optimize too early. We can leave that in the install script and then come back and do more testing once we’ve confirmed the script works as is.

If we can get the script working, then there’s probably more folders in the repository’s src directory that can get the axe as well. The connectors folder seems to include a servlet and IIS module, which probably aren’t needed since we’re working with Apache on Linux. It’s not much, but the more that can be removed that’s not important means that there’s less material to sift through the find the relevant parts we want to work with. So more testing for what can be removed can happen once we have a complete install script.

And the next consideration is the post install script. Since we’re able to work with vanilla Apache, I think that for the post install installation, we want to apt-get apache2, edit the envvars file, copy jaxer.httpd.conf to mods-available, then link the conf file to mods-enabled, copy the compiled jaxer folder to /etc/emrajs, install the service file. And then finally start and enable emrajs and apache2 with the systemctl command.

Attempted to make a single script that will install everything. It almost works except the alias to the client framework is being refused by the Apache configuration. So if we’re able to track down the issue with why that is not being served by Apache, then we’ll have a script that installs Jaxer to /etc/emrajs, and uses vanilla Apache for the file server. So the next blog post will be about the install script and where we can simplify.

Edit 2:
Looks like Apache 2.4 needs the syntax of “require all granted”, works now.