Apache won't start with enabled loadable modules with server sturtup

Hi,
I have two loadable modules: xdata and slimzulu
With them enabled, Apache won't start with a reboot of Ubutu server.

After reboot of Ubuntu, If I execute: sudo service apache2 status

● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: exit-code) since Tue 2020-08-11 09:55:40 SAST; 1min 2
     Docs: man:systemd-sysv-generator(8)
  Process: 1234 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILU

Aug 11 09:55:40 ubuntu apache2[1234]:  *
Aug 11 09:55:40 ubuntu apache2[1234]:  * The apache2 configtest failed.
Aug 11 09:55:40 ubuntu apache2[1234]: Output of config test was:
Aug 11 09:55:40 ubuntu apache2[1234]: apache2: Syntax error on line 140 of /etc/
Aug 11 09:55:40 ubuntu apache2[1234]: Action 'configtest' failed.
Aug 11 09:55:40 ubuntu apache2[1234]: The Apache error log may have more informa
Aug 11 09:55:40 ubuntu systemd[1]: apache2.service: Control process exited, code
Aug 11 09:55:40 ubuntu systemd[1]: Failed to start LSB: Apache2 web server.
Aug 11 09:55:40 ubuntu systemd[1]: apache2.service: Unit entered failed state.
Aug 11 09:55:40 ubuntu systemd[1]: apache2.service: Failed with result 'exit-cod
lines 1-18/18 (END)
● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: exit-code) since Tue 2020-08-11 09:55:40 SAST; 1min 20s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1234 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)

Aug 11 09:55:40 ubuntu apache2[1234]:  *
Aug 11 09:55:40 ubuntu apache2[1234]:  * The apache2 configtest failed.
Aug 11 09:55:40 ubuntu apache2[1234]: Output of config test was:
Aug 11 09:55:40 ubuntu apache2[1234]: apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/slimzulu.load: API module structure 'slimzulu_module' in file /home/nols/PAServer/scratch-dir/Ansie-ubuntu/mod_slimzulu/libmod_slimzulu.so is garbled - expected signature 41503234 but saw 00000000 - perhaps this is not an Apache module DSO, or was compiled for a different Apache version?
Aug 11 09:55:40 ubuntu apache2[1234]: Action 'configtest' failed.
Aug 11 09:55:40 ubuntu apache2[1234]: The Apache error log may have more information.
Aug 11 09:55:40 ubuntu systemd[1]: apache2.service: Control process exited, code=exited status=1
Aug 11 09:55:40 ubuntu systemd[1]: Failed to start LSB: Apache2 web server.
Aug 11 09:55:40 ubuntu systemd[1]: apache2.service: Unit entered failed state.
Aug 11 09:55:40 ubuntu systemd[1]: apache2.service: Failed with result 'exit-code'.

when I then execute: sudo service apache2 start
and then sudo service apache2 status
nols@ubuntu:~$ sudo service apache2 status

● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: active (running) since Tue 2020-08-11 10:37:58 SAST; 1min 48s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1785 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
    Tasks: 55
   Memory: 38.7M
      CPU: 1.040s
   CGroup: /system.slice/apache2.service
           ├─1821 /usr/sbin/apache2 -k start
           ├─1822 /usr/sbin/apache2 -k start
           └─1823 /usr/sbin/apache2 -k start

Aug 11 10:37:55 ubuntu systemd[1]: Starting LSB: Apache2 web server...
Aug 11 10:37:55 ubuntu apache2[1785]:  * Starting Apache httpd web server apache2
Aug 11 10:37:57 ubuntu apache2[1785]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Aug 11 10:37:58 ubuntu apache2[1785]:  *
Aug 11 10:37:58 ubuntu systemd[1]: Started LSB: Apache2 web server.
nols@ubuntu:~$
type or paste code here

If I disable the modules, Apache do load with Ubuntu startup.

The source code of one of the Apache modules is attached.

Regards

Nols SmitSlimzulu.zip (10.1 KB)

Anything might be happening, most probably an error when connecting to the database. Strange errors like that happen because the problem happens in code located in initialization section.

I'd recommend that until you know what's going on and fix the issues, move all your code in initialization and finalization to the WebModule1DefaultHandlerAction method (in correct order of course).

This will not cause an error in Apache initialization and you will probably see better the error message.

I disabled one of the two modules and for the remaining module I did what you suggested (see attached file) . After compiling and deploying to the server and restarting Ubuntu server, Apache is also restarted.

if I then execute the Linux command (sudo apachectl -M | sort) to list the modules I notice the remaining module is in the list but it don't produce the Json data for the url (http://ubuntu/slimzulu/schools). I get a blank window.

Will you have a look at my changes in the webmodule ?

Regards,

Nols SmitWebModuleUnit1.zip (1.0 KB)

You should call TDatabaseManager.Update and Dispatcher.AddModule before actually dispatching the request (DispatchRequest).
But in addition you can also try to enclose everything in a try..except to show an eventual error message if any:

procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  Adapter: IWebBrokerAdapter;
begin
  try
    Server := TWebBrokerServer.Create;
    FireDacPostgreSQLConnection := TFireDacPostgreSQLConnection.Create(nil);
    TDatabaseManager.Update(TFireDacPostgreSQLConnection.CreateConnection);
    Server.Dispatcher.AddModule(TXDataServerModule.Create(
      'http://ubuntu/slimzulu', TFireDacPostgreSQLConnection.CreateConnection
    ));

    Adapter := TWebBrokerAdapter.Create(Request, Response);
    Server.DispatchRequest(Adapter);


    Server.Free;
    FireDacPostgreSQLConnection.Free;
  except
    on E: Exception do
    begin
      Response.Content := Format('%s: %s', [E.ClassName, E.Message]);
    end;
  end;
end;

Thanks, when I restart Ubuntu server then Postgres and Apache, with my two loadable modules, also start successfully.

Regards,

Nols Smit

1 Like