Recent

Author Topic: Daemon on Debian  (Read 5391 times)

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Daemon on Debian
« on: March 30, 2016, 05:02:06 pm »
I created a daemon, downloaded and configured the debian-service.sh script from the wiki, put everything in the right location, and I get the following error:

Code: [Select]
Failed to start r2server.service: Unit r2server.service failed to load: No such file or directory.
The script is : /etc/init.d/r2server.sh, so I don't understand the ".service" part. I changed the file name to r2server.service.sh, but that didn't help.

What am I doing wrong?

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Daemon on Debian
« Reply #1 on: March 30, 2016, 05:32:35 pm »
Did you start it with sufficient rights? (like as root to debug)
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Daemon on Debian
« Reply #2 on: March 31, 2016, 09:14:49 am »
I think so, I do:

Code: [Select]
sudo service r2server start

mdalacu

  • Full Member
  • ***
  • Posts: 233
    • dmSimpleApps
Re: Daemon on Debian
« Reply #3 on: March 31, 2016, 11:28:55 am »
Have you used the Fedora example? Now Ubuntu and Debian are using systemd.

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Daemon on Debian
« Reply #4 on: March 31, 2016, 11:40:30 am »
Ah, thanks. I didn't know that. Last time I managed a Debian server it still used init.d.

Will fix.

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Daemon on Debian
« Reply #5 on: March 31, 2016, 11:56:08 am »
Yes, that did the trick. I have changed the wiki.

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Daemon on Debian
« Reply #6 on: March 31, 2016, 01:31:20 pm »
I spoke too soon. It seems to work, as in: it doesn't give an error, but the daemon isn't active.

I wrote multiple servers in Lazarus, but this is the first time that I try to make it into an official daemon. So the code that listens to the socket and spawns the worker threads, should work.

The wiki is sparse with information, so I followed the pdf. But that didn't work, either.

I have no idea how I can debug it. I think I'll have to go back to a simple console application.

Edit: I'll try and change the template code to match the pdf.

Edit2:

Code: [Select]
./r2configserver --run
Exception at 000000000042B80A: EStreamError:
Failed to initialize component class "TMyMapper": No streaming method available.

TMyMapper is the TDaemonMapper.


Edit3: I cannot get it to work, so I redid it as a console application. That works flawless.
« Last Edit: March 31, 2016, 03:07:57 pm by SymbolicFrank »

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Daemon on Debian
« Reply #7 on: March 31, 2016, 03:53:34 pm »

I have no idea how I can debug it.
use application.log to write debug information.
Quote from: SymbolicFrank
Edit3: I cannot get it to work, so I redid it as a console application. That works flawless.

Are you using write/writeln? The standard daemon doesn't provide stdin/stdout by itself. You should extend your Daemon with one or more  FILE or TEXTFILE objects to provide input/output streaming, yiu know assignfile, rewrite, etc. Then you can do write(myfile,'whatever');

Note on linux a device is also a file, so this also works for streaming to/from a device, e.g. a socket.
« Last Edit: March 31, 2016, 03:58:46 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Daemon on Debian
« Reply #8 on: April 01, 2016, 04:19:53 pm »
I have a logger build in, but it crashes on the initialization of the components. So there is a single line in the log: "Started", and then the daemon crashes before any more of my code executes.

I assume there is something like a .frm or such file included in the executable as a resource, and that it tries to create those components by reading that resource. And that it crashes there.

 

TinyPortal © 2005-2018