Then the next question is: how to run my .tac file with twist? I don't see option like '-y' in it's --help output.
 
-- 
Kind regards, Roman Mescheryakov
 
 
 
01.03.2017, 05:54, "Glyph Lefkowitz" <gl...@twistedmatrix.com>:
 
On Feb 28, 2017, at 8:11 AM, Роман Мещеряков <romanmescherya...@yandex.ru> wrote:
 
Hello everyone,
today I tried restarting twisted service using sys.execv, and it fails with the following message:
 
> 2017-02-28T18:39:47+0300 [ready_to_setup#debug] Before os.execv: sys.executable is /usr/bin/python and sys.argv are ['/usr/local/bin/twistd', '-ny', 'master_player.tac']
> Another twistd server is running, PID 1939
 
> This could either be a previously started instance of your application or a
> different application entirely. To start a new one, either run it in some other
> directory, or use the --pidfile and --logfile parameters to avoid clashes.
 
My service is started in the following way:
 
PYTHONPATH=. twistd -ny master_player.tac
 
(i.e. without daemonization)
Code to restart is:
 
> d = task.deferLater(self._reactor, seconds,
>                     shared_code.restart_script, self._log, self._reactor)
> # _restart_script_done should never be called
> d.addCallback(self._restart_script_done).addErrback(self._restart_script_failure)
 
where shared_code.restart_script is:
 
> def restart_script(logger, reactor):
>     logger.info("Restarting script...")
>     reactor.stop()
>     sys.stdout.flush()
>     #TODO: force logging system to flush all log files
>     logger.debug("Before os.execv: sys.executable is {sysexec} and sys.argv are {argv}",
>                 sysexec = sys.executable, argv = sys.argv)
>     os.execv(sys.executable, [sys.executable] + sys.argv)
 
Could someone explain to me why does the "Another twistd server is running" error occur and how can I avoid it?
 
twistd writes a .pid file and then attempts to check whether another process on the system has the same PID contained in that file while starting up, to avoid conflicts.
 
Yours is an odd case, because the process with that process-ID is the _current_ process, and perhaps the check ought to even be modified to account for this.
 
Two other options you have are:
 
  1. switch to `twist`, which doesn't write a pidfile
  2. use the option "--pidfile ''" to disable writing a pidfile.
 
I strongly suggest the first option :).
 
-glyph
,

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to