Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-11

FpHttpServer and DaemonApp does not works on Linux

3 messages · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hello,

I'm trying to use a HTTP server with daemon on Linux, but, it does not works. I did a project that is working perfectly well on Windows, but on Linux, although the service is successfully installed, it does not starts the HTTP server.

I followed this tutorial:

http://wiki.freepascal.org/Daemons_and_Services

You can download the project test in attached or in this link:

https://www.dropbox.com/s/ljnq71u7lkpkz3w/daemon.zip

And the shell script:

https://www.dropbox.com/s/slwafuo9tj93ym7/project1.zip

To test, follow these steps:

1. Compile the project1.lpr, and copy the generated executable to "/bin/";
2. Unzip "project1.zip", it is just a shell script, and copy if to
/etc/init.d/, after execute "# chmod +x project1" and  "# service project1
start";
3. Open your browser and access: http://localhost:5445;

Where am I going wrong? Some time ago I've done this test, and if I not mistake it worked.

Silvio Clécio My public projects - github.com/silvioprog
silvioprog
to silvioprog

2013/11/7 silvioprog

Show quoted text 30 lines
Hello, I'm trying to use a HTTP server with daemon on Linux, but, it does not works. I did a project that is working perfectly well on Windows, but on Linux, although the service is successfully installed, it does not starts the HTTP server. I followed this tutorial: http://wiki.freepascal.org/Daemons_and_Services You can download the project test in attached or in this link: https://www.dropbox.com/s/ljnq71u7lkpkz3w/daemon.zip And the shell script: https://www.dropbox.com/s/slwafuo9tj93ym7/project1.zip To test, follow these steps: 1. Compile the project1.lpr, and copy the generated executable to "/bin/"; 2. Unzip "project1.zip", it is just a shell script, and copy if to /etc/init.d/, after execute "# chmod +x project1" and "# service project1 start"; 3. Open your browser and access: http://localhost:5445; Where am I going wrong? Some time ago I've done this test, and if I not mistake it worked.

Seems that problem is in the script. I changed it to the draft code (based on
http://www.linuxforums.org/forum/newbie/97097-how-create-linux-service-daemon.html) below and it worked fine:

#!/bin/bash

case "$1" in
start)
# Start daemons.
echo -n "Starting /bin/project1 daemon: "
echo
start-stop-daemon -S -b -x /bin/project1 -- -r
echo

    ;;
  stop)
    # Stop daemons.
    echo -n "Shutting down /bin/project1: "

start-stop-daemon -K -x /bin/project1 -- -r
echo
# Do clean-up works here like removing pid files from /var/run, etc.

    ;;
  status)
    status /bin/project1
    ;;
  restart)
    $0 stop
    $0 start
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|restart}"
    exit 1

esac
exit 0

Silvio Clécio My public projects - github.com/silvioprog
silvioprog
to silvioprog

2013/11/7 silvioprog

Show quoted text 68 lines
2013/11/7 silvioprog > Hello, > > I'm trying to use a HTTP server with daemon on Linux, but, it does not > works. I did a project that is working perfectly well on Windows, but on > Linux, although the service is successfully installed, it does not starts > the HTTP server. > > I followed this tutorial: > > http://wiki.freepascal.org/Daemons_and_Services > > You can download the project test in attached or in this link: > > https://www.dropbox.com/s/ljnq71u7lkpkz3w/daemon.zip > > And the shell script: > > https://www.dropbox.com/s/slwafuo9tj93ym7/project1.zip > > To test, follow these steps: > > 1. Compile the project1.lpr, and copy the generated executable to "/bin/"; > 2. Unzip "project1.zip", it is just a shell script, and copy if to > /etc/init.d/, after execute "# chmod +x project1" and "# service project1 > start"; > 3. Open your browser and access: http://localhost:5445; > > Where am I going wrong? Some time ago I've done this test, and if I not > mistake it worked. > Seems that problem is in the script. I changed it to the draft code (based on http://www.linuxforums.org/forum/newbie/97097-how-create-linux-service-daemon.html) below and it worked fine: #!/bin/bash case "$1" in start) # Start daemons. echo -n "Starting /bin/project1 daemon: " echo start-stop-daemon -S -b -x /bin/project1 -- -r echo ;; stop) # Stop daemons. echo -n "Shutting down /bin/project1: " start-stop-daemon -K -x /bin/project1 -- -r echo # Do clean-up works here like removing pid files from /var/run, etc. ;; status) status /bin/project1 ;; restart) $0 stop $0 start ;; *) echo $"Usage: $0 {start|stop|status|restart}" exit 1 esac exit 0

Final script that works fine:

https://code.google.com/p/lazarus-br/source/browse/trunk/tip/linux-daemon-service-silvioprog

Silvio Clécio My public projects - github.com/silvioprog