Re: Apache suspend/resume (again)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2024-09-21 at 13:16 +0100, Patrick O'Callaghan wrote:
> [Rather than adding to an existing thread (which discusses AVCs from
> crontab among other things, this is starting from a clean slate to
> reduce confusion.]
> 
> 1. I run httpd via systemd for a small personal web service. This
> works.
> 
> 2. I suspend my system overnight and wake it automatically in the
> morning). This turns out to be irrelevant, because the problem reported
> here occurs even when I do it manually.
> 
> 3. On resuming, everything is up *except* httpd.
> 
> 4. The journal (see below) shows that httpd does resume with the rest
> of the system, but then is immediately deactivated. The reason for this
> is not stated (there's no error message), but may be because on the
> system resume the network is not yet up. A similar thing seems to
> happen to certbot, though I haven't looked at it in detail.
> 
> Here's the relevant section from the journal:
> 
> Sep 21 13:04:12 Bree systemd[1]: httpd.service: Deactivated successfully.
> Sep 21 13:04:12 Bree systemd[1]: httpd.service: Consumed 2.980s CPU time.
> Sep 21 13:04:14 Bree NetworkManager[1214]: <info>  [1726920254.0080] device (enp12s0): carrier: link connected
> Sep 21 13:04:14 Bree kernel: r8169 0000:0c:00.0 enp12s0: Link is Up - 1Gbps/Full - flow control rx/tx
> 
> I assume there's a systemd mechanism for getting httpd to wait for the
> network before resuming, but I've no idea how to accomplish this.
> 
> poc

I made some simplifications and the problem seems to have gone away, at
least in the past few days, though I'm not entirely sure what made the
difference. Fingers crossed.

1) I'm no longer doing anything with crontab

2) I've replaced apachectl with systemctl httpd. I don't see any reason
why this should matter, but there you are.

3) I'm not trying to be "graceful", just stopping/starting httpd.

4) Although I did test the httpd.socket service, I'm not using it.

5) I have the following script in /lib/systemd/system-
sleep/apache.sleep:

   #!/bin/bash
   # Hooks to suspend/resume Apache
   #

   LOG=/var/log/httpd/my-log

   log() {
           (echo "$(date): Apache $1") >> $LOG
   }

   running() {
           systemctl is-active httpd > /dev/null
           return $?
   }

   case $1 in
           pre)    if running; then
                           if systemctl stop httpd; then
                                   log "stopping"
                           else
                                   log "stop failed"
                           fi
                   else
                           log "not running"
                   fi
                   ;;

           post)   if running; then
                           log "resumed"
                   else
                           log "starting ..."
                           if systemctl start httpd; then
                                   log "... succeeded"
                           else
                                   log "... failed"
                           fi
                   fi
   esac

Thanks to all who chipped in.

poc
-- 
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux