I have two virtual Ubuntu Servers which are equal and both have Squid Proxy on them.
The problem is that Squid on server startup creates .pid file, but after 10-20 seconds it disappears and I have to manually type:
/usr/local/squid/sbin/squid
Then it works as it should and .pid file does not disappear.
I want my Squid to start on server startup and that .pid file does not disappear.
I have tried creating init.d file /etc/init.d/run_squid
#! /bin/sh
/usr/local/squid/sbin/squid
exit0
then
update-rc.d run_squid defaults
update-rc.d run_squid enable
And I get:
error: run_squid Default-Start contains no runlevels, aborting
I also have tried
crontab -e
@reboot /scripts/squid.sh
and nothing happens when I run it , even If I give permissions.
I need .pid to run properly so my cluster works correctly ( my cluster is made of corosync and pacemaker) ,because the problem now is that when one of nodes .pid disappears, then that node simply continues working(it simply does not proxy, but it thinks it works) , but it does not switch to the healthy one.
To conclude: I want my squid to start properly that it does not lose it's pid and nodes switch if one of them lose .pid file.
Best Answer
Solution for this problem is: We have to create systemd service, so the first thing is to create a service
Then begins case sensitive part:
Then we have to go to the
And now we are able to start squid service by typing:
And to make this service start every time when we start server we have to type