-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to run a Harbour application as a service on a Linux Server #248
Comments
There are so many solutions to run something as a service. These days you'd probably like to see a systemd solution template. There is simple posix deamon in hbunix contrib which puts app itself into the background: You can add a line to cron using I hope that others will share their precious solutions. I'm not complaining that the gcc compiler does not help me in running an app as a service on Linux, maybe the others thought the same about Harbour, so we don't have anything else than posix deamon in the repository. |
netio is a good example of a service that runs on win/linux.
Here is what I use on Ubuntu:
#! /bin/sh
### BEGIN INIT INFO
# Provides: hbnetio
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Harbour NetIO server
### END INIT INFO
set -e
# /etc/init.d/netio: start and stop the Harbour hbnetio daemon
# to install the service
# copy this file (or symlink) into /etc/init.d/
# update-rc.d netio defaults
# start the service with: service netio start
EXE=/Sandbox/harbour/bin/linux/gcc/hbnetio
CONF=/etc/hbnetio.conf
PID=/run/hbnetio.pid
umask 022
PORT=2941
IFACE=0.0.0.0
ROOTDIR=/srv/netiodir
RPC=-rpc
NOUI=-noui
PASS=yoursecretpassword
if test -f $CONF; then
. $CONF
fi
OPTS="-port=$PORT -iface=$IFACE -rootdir=$ROOTDIR $RPC $NOUI -pass=$PASS"
echo $OPTS
. /lib/lsb/init-functions
# Are we running from init?
run_by_init() {
([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
}
check_privsep_dir() {
# Create the PrivSep empty dir if necessary
if [ ! -d /run/hbnetio ]; then
mkdir /run/hbnetio
chmod 0755 /run/hbnetio
fi
}
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in
start)
check_privsep_dir
log_daemon_msg "Starting Harbour NetIO server" "hbnetio" || true
if start-stop-daemon -b --make-pidfile --start --quiet --oknodo
--chuid 0:0 --pidfile $PID --exec $EXE -- $OPTS; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
stop)
log_daemon_msg "Stopping Harbour NetIO server" "hbnetio" || true
if start-stop-daemon --remove-pidfile --stop --quiet --oknodo
--pidfile $PID --exec $EXE; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
restart)
check_privsep_dir
log_daemon_msg "Restarting Harbour NetIO server" "hbnetio" || true
log_daemon_msg "Stopping Harbour NetIO server" "hbnetio" || true
start-stop-daemon --remove-pidfile --stop --quiet --oknodo --retry
30 --pidfile $PID --exec $EXE
log_daemon_msg "Starting Harbour NetIO server" "hbnetio" || true
if start-stop-daemon -b --make-pidfile --start --quiet --oknodo
--chuid 0:0 --pidfile $PID --exec $EXE -- $OPTS; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
status)
status_of_proc -p $PID $EXE hbnetio && exit 0 || exit $?
;;
*)
log_action_msg "Usage: /etc/init.d/ssh {start|stop|restart|status}"
|| true
exit 1
esac
exit 0
…On Tue, Jun 22, 2021 at 2:18 PM alcz ***@***.***> wrote:
There are so many solutions to run something as a service. These days
you'd probably like to see a systemd solution template.
Nobody contributed i guess. Other than that i highly doubt that everything
in Harbour is geared to run on Windows.
There is simple posix deamon in hbunix contrib which puts app itself into
the background:
https://github.com/harbour/core/blob/master/contrib/hbunix/tests/daemon.prg
You can add a line to cron using crontab -e
@reboot /path/to/app //gtnul
I hope that others will share their precious solutions. I'm not
complaining that the gcc compiler does not help me in running an app as a
service on Linux, maybe the others thought the same about Harbour, so we
don't have anything else than posix deamon in the repository.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#248 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABTQJTYAN3ZSMSD47I6C5RTTUDHWPANCNFSM47EE677Q>
.
|
Hi @prgwiz, thank you very much for answering, I am inexperienced in Linux, I know the content above is an example and from what I understand it is a type of script, in which directory and with what name do I save it? This content points to several directories and files that I would have to look at to understand what it is doing, for example "CONF=/etc/hbnetio.conf", seems to be more complex than I expected. Someone must have a simpler example of Harbour as a service. Translated with www.DeepL.com/Translator (free version) |
I realized that everything in Harbour is geared to run on Windows. There is nothing here of examples of how to run an application in Harbour as an Ubuntu server service or CentOS server, without a GUI.
The text was updated successfully, but these errors were encountered: