In Ubuntu 16.04 all services are written inside /etc/systemd/system/ directory. If we want create a service for varnish, we can create the following file under the above (/etc/systemd/system/) directory.
Service file name: varnish.service
Copy the following content to the varnish.service file:
Now we need to create the startup.sh and shutdown.sh file under /usr/local/varnish directory. Inside the .sh file we need to run the varnish server with a port with a .vcl file. We need to run it so that it uses memory (ram) for higher performance. For running varnish from .sh file we have lots of options but the simplest is as follows:
Similarly we also need to create the shutdown.sh file under /usr/local/varnish directory. Following is the content of the shutdown.sh file:
Service file name: varnish.service
Copy the following content to the varnish.service file:
[Service] Type=forking ExecStart=/usr/local/varnish/startup.sh ExecStop=/usr/local/varnish/shutdown.sh RestartSec=10 Restart=always
Now we need to create the startup.sh and shutdown.sh file under /usr/local/varnish directory. Inside the .sh file we need to run the varnish server with a port with a .vcl file. We need to run it so that it uses memory (ram) for higher performance. For running varnish from .sh file we have lots of options but the simplest is as follows:
#!/bin/sh sudo varnishd -a :7070 -f-T 0.0.0.0:2000
Similarly we also need to create the shutdown.sh file under /usr/local/varnish directory. Following is the content of the shutdown.sh file:
#!/bin/sh sudo pkill varnishd
Comments
Post a Comment