--daemonize not working · Issue #19 · TelegramMessenger/MTProxy · GitHub
2018-10-18 22:51:32 Author: github.com(查看原文) 阅读量:195 收藏

Join GitHub today

GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.

Sign up

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

Comments

@FreedomPrevails

--daemonize has no effect. process stays in foreground.

@loskiq

This comment has been minimized.

@loskiq

loskiq May 31, 2018

Contributor

You can install MTProxy as a systemd service. Example:

[Unit]
Description=MTProxy
After=network.target

[Service]
WorkingDirectory=/opt/mtproxy
ExecStart=/opt/mtproxy/mtproto-proxy -u nobody -p 8888 -H 443 -S 77f059e1822e2b23e84eda9c5f964091 --aes-pwd proxy-secret proxy-multi.conf -M 1

[Install]
WantedBy=multi-user.target

You can install MTProxy as a systemd service. Example:

[Unit]
Description=MTProxy
After=network.target

[Service]
WorkingDirectory=/opt/mtproxy
ExecStart=/opt/mtproxy/mtproto-proxy -u nobody -p 8888 -H 443 -S 77f059e1822e2b23e84eda9c5f964091 --aes-pwd proxy-secret proxy-multi.conf -M 1

[Install]
WantedBy=multi-user.target

@p1ratrulezzz

This comment has been minimized.

@p1ratrulezzz

p1ratrulezzz May 31, 2018

Same for me. I use start-stop-daemon

Upd: use the example above by @loskiq unless your Linux is very old and doesn't support systemd

#!/bin/sh
### BEGIN INIT INFO
# Provides: mtproto-proxy
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Default-Start:        2 3 4 5
# Default-Stop:
# Short-Description:    MTProxy service
### END INIT INFO

set -e

# Must be a valid filename
NAME=mtproto-proxy
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/usr/bin/mtproto-proxy
DIR=/opt/MTProxy
DAEMON_OPTS=$(cat ${DIR}/options.txt)
USER=root

export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"

case "$1" in
  start)
        echo -n "Starting daemon: "$NAME
        start-stop-daemon --start --background --pidfile $PIDFILE -d $DIR -m --exec $DAEMON -- $DAEMON_OPTS
        echo "."
        ;;
  stop)
        echo -n "Stopping daemon: "$NAME
        start-stop-daemon --stop --signal TERM --quiet --oknodo --pidfile $PIDFILE
        echo "."
        sleep 3
        ;;
  restart)
        echo -n "Restarting daemon: "$NAME
        start-stop-daemon --stop --signal TERM --quiet --oknodo --retry 30 --pidfile $PIDFILE
        start-stop-daemon --start --background --pidfile $PIDFILE -d $DIR -m --exec $DAEMON -- $DAEMON_OPTS
        echo "."
        ;;

  *)
        echo "Usage: "$1" {start|stop|restart}"
        exit 1
esac

exit 0

Same for me. I use start-stop-daemon

Upd: use the example above by @loskiq unless your Linux is very old and doesn't support systemd

#!/bin/sh
### BEGIN INIT INFO
# Provides: mtproto-proxy
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Default-Start:        2 3 4 5
# Default-Stop:
# Short-Description:    MTProxy service
### END INIT INFO

set -e

# Must be a valid filename
NAME=mtproto-proxy
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/usr/bin/mtproto-proxy
DIR=/opt/MTProxy
DAEMON_OPTS=$(cat ${DIR}/options.txt)
USER=root

export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"

case "$1" in
  start)
        echo -n "Starting daemon: "$NAME
        start-stop-daemon --start --background --pidfile $PIDFILE -d $DIR -m --exec $DAEMON -- $DAEMON_OPTS
        echo "."
        ;;
  stop)
        echo -n "Stopping daemon: "$NAME
        start-stop-daemon --stop --signal TERM --quiet --oknodo --pidfile $PIDFILE
        echo "."
        sleep 3
        ;;
  restart)
        echo -n "Restarting daemon: "$NAME
        start-stop-daemon --stop --signal TERM --quiet --oknodo --retry 30 --pidfile $PIDFILE
        start-stop-daemon --start --background --pidfile $PIDFILE -d $DIR -m --exec $DAEMON -- $DAEMON_OPTS
        echo "."
        ;;

  *)
        echo "Usage: "$1" {start|stop|restart}"
        exit 1
esac

exit 0

This was referenced May 31, 2018

@p1ratrulezzz

This comment has been minimized.

@p1ratrulezzz

By the way, it is a bug. Need to label it

@gladiators1980

This comment has been minimized.

@gladiators1980

in centos 6.9 how to set ?

@p1ratrulezzz

This comment has been minimized.

@p1ratrulezzz

Google it using "centos systemd create"


文章来源: https://github.com/TelegramMessenger/MTProxy/issues/19
如有侵权请联系:admin#unsafe.sh