Forum

Hiawatha fails to start on boot, but starts on command

Ron Jones
3 July 2017, 19:45
BUT... it starts without issue when I give the "systemctl start hiawatha.service" command.

"systemctl list-unit-files" tells me that hiawatha.service is enabled

"tail -f syslog | grep hiawatha" and "tail -f hiawatha/system.log" (observed while running "systemctl restart hiawatha.service" respond with nothing useful, aside from system.log informing me that hiawatha stopped and started).

My first inclination is that I have made a configuration error. But I have tried the Binding config in several different ways, and cannot seem to get it to start without issuing a manual command.
***

Server: Ubuntu 16.04 LTS
Hiawatha version: 10.6

When I reboot the server, Hiawatha does not start on its own.
"$ sudo systemctl status hiawatha.service" returns the following output:

● hiawatha.service - Hiawatha webserver
Loaded: loaded (/lib/systemd/system/hiawatha.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2017-07-03 13:12:10 EDT; 50s ago
Process: 3514 ExecStart=/usr/sbin/hiawatha (code=exited, status=1/FAILURE)
Process: 3491 ExecStartPre=/usr/sbin/wigwam -q (code=exited, status=0/SUCCESS)

Jul 03 13:12:10 TempleBaptist systemd[1]: Starting Hiawatha webserver...
Jul 03 13:12:10 TempleBaptist hiawatha[3514]: Error binding 2600:3c02::f03c:91ff:fe7a:ec10.80
Jul 03 13:12:10 TempleBaptist systemd[1]: hiawatha.service: Control process exited, code=exited status=1
Jul 03 13:12:10 TempleBaptist systemd[1]: Failed to start Hiawatha webserver.
Jul 03 13:12:10 TempleBaptist systemd[1]: hiawatha.service: Unit entered failed state.
Jul 03 13:12:10 TempleBaptist systemd[1]: hiawatha.service: Failed with result 'exit-code'.


"# less syslog | grep hiawatha" returns the following output:

Jul 3 13:12:10 TempleBaptist hiawatha[3514]: Error binding 2600:3c02::f03c:91ff:fe7a:ec10.80
Jul 3 13:12:10 TempleBaptist systemd[1]: hiawatha.service: Control process exited, code=exited status=1
Jul 3 13:12:10 TempleBaptist systemd[1]: hiawatha.service: Unit entered failed state.
Jul 3 13:12:10 TempleBaptist systemd[1]: hiawatha.service: Failed with result 'exit-code'.


hiawatha.conf shown below:
# GENERAL SETTINGS
#
#ServerString = Hiawatha
ServerId = www-data
ConnectionsTotal = 1024
#ConnectionsPerIP = 32 #Default = 15
SystemLogfile = /var/log/hiawatha/system.log
GarbageLogfile = /var/log/hiawatha/garbage.log
ExploitLogfile = /var/log/hiawatha/exloit.log
ThreadKillRate = 3
#DHsize = 4096 #default 2048, for tls
CacheSize = 64
LogfileMask = deny MyIPv4, deny TrustedIP_1
RequestLimitMask = deny TrustedIP_1
ReconnectDelay = 2

# BINDING SETTINGS
# A binding is where a client can connect to.
#
Binding {
Port = 80
Interface = MyIPv4
TimeForRequest = 5,23
MaxRequestSize = 512
MaxUploadSize = 16
}
#
#Binding {
# Port = 443
# TimeForRequest = 5,23
# MaxRequestSize = 512
# MaxUploadSize = 16
# #TLScertFile = /path/to/file
#}
#
Binding {
Port = 80
Interface = MyIPv6
TimeForRequest = 5,23
MaxRequestSize = 512
MaxUploadSize = 16
}
#
#Binding {
# Port = 443
# Interface = MyIPv6
# TimeForRequest = 5,23
# TLScertFile = /path/to/file
# MaxRequestSize = 512
# MaxUploadSize = 16
#}

# BANNING SETTINGS
# Deny service to clients who misbehave.
#
BanlistMask = deny LOCALHOST, deny TrustedIP_1, deny MyIPv4
RequestLimitMask = deny TrustedIP_1
#
ChallengeClient = 200, httpheader, 60
BanOnGarbage = 15
BanOnMaxPerIP = 5 #Default = 2
BanOnMaxReqSize = 15
BanOnDeniedBody = 15
BanOnFlooding = 30/1:15
KickOnBan = yes
RebanDuringBan = yes


# COMMON GATEWAY INTERFACE (CGI) SETTINGS
# These settings can be used to run CGI applications.
#
#CGIhandler = /usr/bin/perl:pl
CGIhandler = /usr/bin/php7.0:php
#CGIhandler = /usr/bin/python:py
#CGIhandler = /usr/bin/ruby:rb
#CGIhandler = /usr/bin/ssi-cgi:shtml
#CGIextension = cgi
#
FastCGIserver {
FastCGIid = PHP7
ConnectTo = /run/php/php7.0-fpm.sock
Extension = php
}

# URL TOOLKIT
# This URL toolkit rule was made for the wordpress CMS,
# which can be downloaded from https://wordpress.org
#
UrlToolkit {
ToolkitID = wordpress
RequestURI exists Return
Match [^?]*(\?.*)? Rewrite /index.php$1
}

# DIRECTORY SETTINGS
# You can specify some settings per directory.
#
Directory {
DirectoryID = assets
Path = /
Extensions = css, js, png, webp, jpg, pdf, woff, woff2
ExpirePeriod = 2 weeks, public
}

# DEFAULT WEBSITE
# It is wise to use your IP address as the hostname of the default website
# and give it a blank webpage. By doing so, automated webscanners won't find
# your possible vulnerable website.
#
Hostname = 66.228.56.204
WebsiteRoot = /var/www/hiawatha
StartFile = index.html
AccessLogfile = /var/log/hiawatha/access.log
ErrorLogfile = /var/log/hiawatha/error.log



# VIRTUAL HOSTS
# Use a VirtualHost section for each website you want to host.
#
VirtualHost {
Hostname = www.tbcgwinnet.org, *.tbcgwinnett.org
#RequireTLS = yes
#TLScertFile = /etc/hiawatha/certs/tbcgwinnett.pem
WebsiteRoot = /var/www/templebc/public_html
StartFile = index.php
UseToolkit = wordpress
UseDirectory = assets
AccessLogfile = /var/log/templebc/access.log, monthly
ErrorLogfile = /var/log/templebc/error.log
ShowIndex = no
TimeForCGI = 10
UseFastCGI = PHP7
CustomHeader = Vary: Accept-Encoding
CustomHeader = X-Frame-Options: sameorigin
#PreventXSS = block
RandomHeader = 768
#PreventCSRF = block
#XSS & CSRF Interfere with some plugins while setting up. Enable AFTER plugins are configured the way you want
}
Ron Jones
3 July 2017, 19:47
Follow-up, Relevant to the settings above are the Variables in my configuration:

set LOCALHOST = 127.0.0.1/8
set MyIPv4 = 66.228.56.204
Set MyIPv6 = 2600:3c02::f03c:91ff:fe7a:ec10
Hugo Leisink
3 July 2017, 21:06
Could it be your system tries to start Hiawatha before the network interfaces are up? That way, Hiawatha can't bind to the specified interfaces.
Ron Jones
3 July 2017, 23:07
Not according to /lib/systemd/system/hiawatha.service
[Unit]
Description=Hiawatha webserver
After=network.target

[Service]
Type=forking
PIDFile=/var/run/hiawatha.pid
ExecStartPre=/usr/sbin/wigwam -q
ExecStart=/usr/sbin/hiawatha
ExecStop=/bin/kill $MAINPID
KillMode=process
TimeoutStopSec=5

[Install]
WantedBy=multi-user.target
Ron Jones
3 July 2017, 23:20
TL;DR = removing IPv6 seems to make it work. Perhaps I'm making a configuration error in the IPv6 Binding? See below for details.

I edited my config file (above) and commented out the Binding information for Port 80 of IPv6. The binding section now is:
# BINDING SETTINGS
# A binding is where a client can connect to.
#
Binding {
Port = 80
Interface = MyIPv4
TimeForRequest = 5,23
MaxRequestSize = 512
MaxUploadSize = 16
}
#
#Binding {
# Port = 443
# Interface = MyIPv4
# TimeForRequest = 5,23
# MaxRequestSize = 512
# MaxUploadSize = 16
# #TLScertFile = /path/to/file
#}
#
#Binding {
# Port = 80
# Interface = MyIPv6
# TimeForRequest = 5,23
# MaxRequestSize = 512
# MaxUploadSize = 16
#}
#
#Binding {
# Port = 443
# Interface = MyIPv6
# TimeForRequest = 5,23
# TLScertFile = /path/to/file
# MaxRequestSize = 512
# MaxUploadSize = 16
#}

When I rebooted the machine, Hiawatha started as it should (see below)

jonesre@TempleBaptist:~$ sudo systemctl status hiawatha.service
● hiawatha.service - Hiawatha webserver
Loaded: loaded (/lib/systemd/system/hiawatha.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2017-07-03 17:14:43 EDT; 29s ago
Process: 3500 ExecStart=/usr/sbin/hiawatha (code=exited, status=0/SUCCESS)
Process: 3480 ExecStartPre=/usr/sbin/wigwam -q (code=exited, status=0/SUCCESS)
Main PID: 3518 (hiawatha)
CGroup: /system.slice/hiawatha.service
└─3518 /usr/sbin/hiawatha

Jul 03 17:14:43 TempleBaptist systemd[1]: Starting Hiawatha webserver...
Jul 03 17:14:43 TempleBaptist systemd[1]: Started Hiawatha webserver.
Hugo Leisink
5 July 2017, 01:03
The parameter of 'Interface' should be an IPv4 or IPv6 address. Use the 'BindingID' option to label a binding.
Ron Jones
5 July 2017, 17:08
In Variables, I have set MyIPv4 and MyIPv6

In Binding, I have set the parameter 'Interface' using the set variables.

Unfortunately, 'systemctl status hiawatha.service' still returns the same error immediately after reboot:

Jul 05 10:57:52 srv02 hiawatha[3529]: Error binding 2600:3c02::f03c:91ff:fe60:97a8

Fortunately, it starts right up after logging in via ssh and issuing the command manually.
Hugo Leisink
5 July 2017, 20:38
The only thing I can think of is that the interface is not ready yet at that time. I have no idea why that is.
Ron Jones
6 July 2017, 05:08
You were correct. I opened a support ticket at Linode (my VPS provider), and they were quite helpful.

Even though my VPS comes with a static IP, both 4 and 6, the IPv4 is hard coded, while the IPv6 is handed out at startup (like reserved dhcp I gather). There is just enough of a delay to cause problems. As the support guy put it: "IPv6 can potentially take a few minutes to get fully set up as it will need to wait for a router advertisement to get its IPv6 prefix and finish configuration."

BUT... It is an easy fix, you just have to set both IP's as static in /etc/network/interfaces, then disable the "auto-configure networking" script via a selector button in the dashboard.

It's slicker than a greased pig now.
Hugo Leisink
6 July 2017, 08:57
Nice.
This topic has been closed.