Service units for web applications

Stephen Gallagher sgallagh at redhat.com
Tue Feb 25 20:49:13 UTC 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/25/2014 03:07 PM, Lennart Poettering wrote:
> On Tue, 25.02.14 14:55, Stephen Gallagher (sgallagh at redhat.com)
> wrote:
> 
>> There are actually two pieces to this that I'd like to see (and 
>> hopefully have someone tell me are already possible):
>> 
>> 1. The ability to add new ExecStartPre commands to the httpd
>> service when installing new sites.
> 
> You can do that already, you can extend existing unit files by
> dropping a config snippet into httpd.service.d/foobar.conf. systemd
> will read httpd.service plus all files named *.conf from
> httpd.service.d/ and merge them together. THis can be used by RPMs
> to change or extend unit files of other packages as necessary.
> 


Ah, good to know. Thanks for the tip.


>> 2. The ability to enable and disable specific apache sites from 
>> systemctl. Basically, I'd like to have a symlink added or
>> removed from /etc/httpd/conf.d based on whether
>> httpd-mysite.service was enabled or disabled.
> 
> I am pretty sure that systemctl should not be in the business of 
> managing other packages configuation.
> 
> I am not really grokking here what you want to do though. If you
> want multiple http instances you should give them a differen config
> dir/file each, and expose them using systemd unit templates, e.g.
> httpd at foobar.com.service and so on. These templates can then build 
> a command line for apache that includes the "foobar.com" part of
> this service name, for example to reference a specific
> configuration file. THis is done via specifier expansion ("%i").
> 
> If we want to make it simple to run multiple instances of the
> popular server packages on the system, then we should really start
> shipping good unit file templates like that, so that people don#t
> have to write them first. We could provide both non-templated
> singletons for the common cases, and templated versions for those
> who need this, and people then have the free choice which version
> they want to use.
> 


In the specific case I'm looking at, I'm not (necessarily) talking
about separate httpd instances. Rather, I'm talking about either
different virtual hosts or different paths on the same virtual host.

For example, I might have

http://reviews.myserver.com/systemd-reviews/
http://reviews.myserver.com/networkmanager-reviews/
http://otherreviews.myserver.com/

All of these would be operating under a single HTTPD instance on port
80, just with configuration enabling them to run different instances
of the same application in different paths and on different virtual hosts.

In the case of apache, it really amounts to something very similar to
what you explained about the service snippets above. You just drop a
file like the one copied below into the /etc/httpd/conf.d/ directory
and it gets merged together when apache starts. From my perspective as
a user, these really are individual services, they just happen to be
running inside the same process. So I would ideally want to be able to
enable and disable them the way I would the httpd service itself.




<VirtualHost *:80>
	ServerName reviews.myserver.com
	DocumentRoot "/srv/reviewboard1721/htdocs"
	ErrorDocument 500 /errordocs/500.html
	WSGIPassAuthorization On
	WSGIScriptAlias "/reviewboard"
"/srv/reviewboard1721/htdocs/reviewboard.wsgi/reviewboard"
	<Directory "/srv/reviewboard1721/htdocs">
		AllowOverride All
		Options -Indexes +FollowSymLinks
		Require all granted
	</Directory>
	<Location "/reviewboard/media/uploaded">
		SetHandler None
		Options None
		AddType text/plain .html .htm .shtml .php .php3 .php4 .php5 .phps .asp
		AddType text/plain .pl .py .fcgi .cgi .phtml .phtm .pht .jsp .sh .rb
		<IfModule mod_php5.c>
			php_flag engine off
		</IfModule>
	</Location>
	Alias /reviewboard/media "/srv/reviewboard1721/htdocs/media"
	Alias /reviewboard/static "/srv/reviewboard1721/htdocs/static"
	Alias /reviewboard/errordocs "/srv/reviewboard1721/htdocs/errordocs"
	Alias /reviewboard/favicon.ico
"/srv/reviewboard1721/htdocs/static/rb/images/favicon.png"
</VirtualHost>


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlMNAckACgkQeiVVYja6o6Pj3gCdGE/GHIDx0xstefBDCuX/OCDu
bqgAn18vRjVjMt2IALhfUuxBdckpgA0O
=+V5M
-----END PGP SIGNATURE-----


More information about the devel mailing list