How to restart service like httpd in custom script all_post.sh

defomaz

Verified User
Joined
Jun 26, 2008
Messages
130
Halo,

I create custom script all_post.sh that need restart service like apache.

Code:
#!/bin/sh
if [ "$command" = "/CMD_SSL" ] && [ "$submit" = "Save" ]; then
   bla bla bla...
   service httpd restart
fi
exit 0

but when click save button in ssl, process loading and hang.

Thanks in advance
 
Hello,

It most likely that the script is executed in behalf of an user who has no permissions to restart apache, or you might need to specify full paths for "service".
 
Yes.

The script is executed either in behalf of user "diradmin" or other user... anyway it's not root, so the user has no permissions to restart apache. I'd rather think it is "diradmin". In such a case you might consider using a deferred restart with:

Code:
echo "action=httpd&value=restart" >> /usr/local/directadmin/data/task.queue

with this Apache will be restarted with a Directadmin cron within 1 minute.
 
Yes.

The script is executed either in behalf of user "diradmin" or other user... anyway it's not root, so the user has no permissions to restart apache. I'd rather think it is "diradmin". In such a case you might consider using a deferred restart with:

Code:
echo "action=httpd&value=restart" >> /usr/local/directadmin/data/task.queue

with this Apache will be restarted with a Directadmin cron within 1 minute.

Thank you, Its working for httpd.

and how about if I use like this.

echo "action=varnish&value=restart" >> /usr/local/directadmin/data/task.queue

It's seem not working for other custom service.
 
Yes, it seems not working for custom services. So you might need to write your own script and run it the same with cron.

I wonder why do you need to restart varnish on any action with SSL?
 
Not varnish actually but I create pem file for Haproxy SSL termination.

I'm using crt-list

Code:
[root@server4 ~]# cat /etc/haproxy/crt_list.pem
/home/xxxinfo/domains/xxxainfo.com/ssl.pem
/home/xxinfo/domains/xxxenulis.com/ssl.pem
/home/xxxorma/domains/xxxxormal.com/ssl.pem

So all ssl traffic => haproxy => varnish => apache

and to get this working, I use custom script /CMD_SSL and then need restart haproxy.
 
OK, I see. So there are two possible ways to go further:

1. as it was already mentioned to run your own script with cron and restart haproxy
2. or ask Directadmin developers to add this as a feature. So if we have a service in Directadmin monitor (listed in /usr/local/directadmin/data/admin/services.status) then Directadmin could restart it with:

Code:
echo "action=<service-name>&value=restart" >> /usr/local/directadmin/data/task.queue

that might be a bug in Directadmin, so try and open a ticket with them.
 
Back
Top