Skip to content

Platform Stacks: Works In Progress

orblivion edited this page Mar 4, 2020 · 4 revisions

When creating or porting a sandstorm app, we usually rely on various common services such as nginx, mysql, etc that the app requires. Given Sandstorm's restrictive environment (single user, /var/ home directory, etc), these services usually don't work out of the box. When we do figure out how to get them to work, we try to put them into a pre-baked set of scripts called a Platform Stack.

Sometimes, we get part of the way there. Either the developer had to move on to something else, or they found a workaround with an alternative service. In such a case it's still worth documenting what we've figured out so far, so that it can benefit the next person who tries the same. This page should contain abandoned (if temporarily) Works-In-Progress of porting these various services.

Apache

By: https://github.com/orblivion/

I tried for a little while to get Apache2 to run within a Sandstorm grain environment. I bailed on it when I found a workaround in my project, and was advised that it wasn't a high priority for use in other projects.

Like many of the tools we use (Nginx, mysql, etc), apache2 is designed to work as a daemon, controlled by some sort of supervisor. It seems to be especially true for Apache, as I read advice in many places not to run the executable directly. An actual supervisor isn't very appropriate to a Sandstorm grain environment, but in the future we might consider a sort of fake one that gives the right environment conditions necessary for something like Apache. It could make other tools easier to use as well.

For now, here's what I tried. I'll include my process since it'll expose some of the moving parts you'll need to play with. First I started here:

/usr/sbin/apache2 -D FOREGROUND -D NO_DETACH

Foreground and no detach (no forking) for simplicity, I presumed. Perhaps not useful to us in the end.

This gives me the following error:

apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot

Looking in /etc/apache2/apache2.conf, we see:

DefaultRuntimeDir ${APACHE_RUN_DIR}

Looking this up (and also confirmed if you browse /etc/apache2/apache2.conf), we need to source /etc/apache2/envvars to give us APACHE_RUN_DIR:

source /etc/apache2/envvars
/usr/sbin/apache2 -D FOREGROUND -D NO_DETACH

This gives us the following error:

/etc/apache2/envvars: line 7: APACHE_CONFDIR: unbound variable

Looking in /etc/apache2/envvars, we see:

if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then

The way APACHE_CONFDIR works was a bit confusing so I just set it to an empty string and echoed $APACHE_RUN_DIR to see how it would be set:

export APACHE_CONFDIR=""
source /etc/apache2/envvars
echo "APACHE_RUN_DIR $APACHE_RUN_DIR"
/usr/sbin/apache2 -D FOREGROUND -D NO_DETACH &

And I get:

APACHE_RUN_DIR /var/run/apache2
apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot

Looks sort of like I'm back where I started, but at least DefaultRuntimeDir is probably set given that APACHE_RUN_DIR is set. Maybe we need to set ServerRoot properly next.

But that's as far as I got.

Clone this wiki locally