logIt Log Around The Clock

Running Two Squid Instances in Upstart Init

After installing squid3 from repository, Ubuntu will place the init in upstart style (instead of /etc/rc*.d/ or /etc/init.d/ style used to maintain backward compatibility to legacy System-V init). The upstart job is placed in /etc/init/squid3.conf with default runlevel (2,3,4 or 5) to start the instance during reboot and relevant start/stop command using service:

$ sudo service squid3 {start|stop|restart}

To specify what to run, an upstart must have exec or script stanza. When the goal is to start two or more (multiple) instances of squid3, exec is meant to replace existing process image of /usr/sbin/squid3 executable, therefore will not start two instances.

Eltek Smartpack Controller type with SNMP Support

Multiple squid3 instances started via upstart exec

As workaround we can have symbolic link to squid3 executable instead and add new upstart job configuration with exec call to the link. I need two instances running in the same machine due to the implementation design where the fist instance is HTTP proxy cache while the second one is accelerator/interceptor (reverse proxy) that serves default landing page telling user to use proxy (and how to do that). Hence, for the second instance I add:

lrwxrwxrwx 1 root root 6 May  3 09:25 /usr/sbin/squid3ins2 -> squid3
-rw-r--r-- 1 root root 1156 May  6 13:30 /etc/init/squid3ins2.conf

and for the first instance I add:

-rw-r--r-- 1 root root 298 May  3 10:13 /etc/init/squid3.override

squid3ins2 is our link and /etc/init/squid3ins2.conf contains exec call to it to run second squid3. For the first instance I choose to write an override (/etc/init/squid3.override) so that the original job configuration file is left intact. For the complete content of all files check my github v1.1 of the Squid integration. There, in details you’ll also find how both instances PID, log, etc. are differentiated by each instance config via the following directives:


Leave a Reply