Sure I'd at least see if things work fine using waitress to try and confirm that it's a uwsgi issue. I'm sure uwsgi can be fixed to deal with the subprocesses better but I do not know how myself.
On Tue, Mar 3, 2020 at 1:39 PM Emerson Barea <emerson.ba...@gmail.com> wrote: > So I'll look for another python server than uwsgi to run my app. > > Thank you Michael. > > > Em terça-feira, 3 de março de 2020 15:40:42 UTC-3, Michael Merickel > escreveu: >> >> I suspect it's something to do with UWsgi doing funky things with fork >> and subprocesses. For example >> https://stackoverflow.com/questions/17592692/running-a-subprocess-in-uwsgi-application >> . >> >> On Tue, Mar 3, 2020 at 12:37 PM Emerson Barea <emerso...@gmail.com> >> wrote: >> >>> Hi Michael, thanks for your reply. I'm sorry I didn't confirm it >>> earlier, but I've been quite sick this past week. >>> >>> Well, I tried to follow the suggestion you made, making the following >>> changes: >>> >>> scripts/tests.py >>> >>> def main(argv): >>> <my code here> >>> >>> >>> if __name__ == '__main__': >>> main(argv=sys.argv[1:]) >>> >>> >>> >>> my view code: >>> >>> arguments = ['--config_file=minisecbgp.ini', >>> '--execution_type=create_node', >>> '--hostname=%s' % form.node.data, >>> '--username=%s' % form.username.data, >>> '--password=%s' % form.password.data] >>> #subprocess.Popen(['tests'] + arguments) >>> subprocess.Popen([sys.executable, '-m', 'minisecbgp.scripts.tests'] + >>> arguments) >>> >>> >>> and now I receive this erro when I try to execute the view in browser: >>> >>> Mar 3 15:24:57 lpttch uwsgi[7284]: /home/tocha/Documentos/projetos/ >>> MiniSecBGP/venv/bin/uwsgi: unrecognized option >>> '--config_file=minisecbgp.ini' >>> Mar 3 15:24:57 lpttch uwsgi[7284]: getopt_long() error >>> >>> I tried to modify the setyp.py console_scripts to >>> >>> 'tests = minisecbgp.scripts.tests' >>> >>> or removing this entry_point, since the call to the script is being made >>> directly now, but I always got the same error. >>> >>> Please, do you known what I'm doing wrong? >>> >>> Thank you. >>> >>> Emerson >>> >>> >>> Em quinta-feira, 27 de fevereiro de 2020 21:28:04 UTC-3, Michael >>> Merickel escreveu: >>> >>>> Your environment isn't modifying the env PATH, which is what Popen is >>>> relying on to find the script. >>>> >>>> It'd be better not rely on the PATH and instead just run the code using >>>> `python -m foo`, but that doesn't actually work with console scripts. You >>>> would instead do `subprocess.Popen([sys.executable, '-m', >>>> 'minisecbgp.scripts.config'] + arguments)`. You'd then need to define an >>>> `if __name__ == '__main__': main()` in your script instead of relying on >>>> the console script to invoke your main function. >>>> >>>> Alternatively fix your PATH, but I find that less ideal because it can >>>> change per-environment where the console scripts are actually installed. >>>> >>>> - Michael >>>> >>>> On Thu, Feb 27, 2020 at 5:41 PM Emerson Barea <emerso...@gmail.com> >>>> wrote: >>>> >>>>> Hi there. >>>>> >>>>> My application has some scripts on .app.scripts (.app.scripts.tests >>>>> and .app.scripts.config). >>>>> >>>>> I configured this scripts in setup.py file like this: >>>>> >>>>> entry_points={ >>>>> 'paste.app_factory': [ >>>>> 'main = minisecbgp:main' >>>>> ], >>>>> 'console_scripts': [ >>>>> 'initialize_minisecbgp_db = >>>>> minisecbgp.scripts.initialize_db:main', >>>>> 'tests = minisecbgp.scripts.tests:main', >>>>> 'validate_hostname = minisecbgp.scripts.validate_hostname:main', >>>>> 'config = minisecbgp.scripts.config:main', >>>>> ], >>>>> >>>>> >>>>> I call these two scripts in my view with the code below: >>>>> >>>>> arguments = ['--config_file=minisecbgp.ini', >>>>> '--hostname=%s' % form.node.data, >>>>> '--username=%s' % form.username.data, >>>>> '--password=%s' % form.password.data] >>>>> subprocess.Popen(['config'] + arguments) >>>>> >>>>> >>>>> and, when I run my application with the commands below, everything >>>>> works well. The page works fine and the scripts tests and config works >>>>> well. >>>>> >>>>> pip install -e ".[testing]" >>>>> pserve minisecbgp.ini --reload >>>>> >>>>> >>>>> So, I want to put my app in production, and I'm trying to use uwsgi >>>>> and nginx to do it. When I configured uwsgi and nginx and open the app in >>>>> browser, the app works well, but when I call the view that executes the >>>>> scripts tests and config, I receave a 502 bad gateway error. Looking at >>>>> syslog file, I receaved this error: >>>>> >>>>> Feb 27 20:12:56 lpttch uwsgi[14110]: subprocess.Popen(['tests'] + >>>>> arguments) >>>>> Feb 27 20:12:56 lpttch uwsgi[14110]: File >>>>> "/usr/lib/python3.6/subprocess.py", line 729, in __init__ >>>>> Feb 27 20:12:56 lpttch uwsgi[14110]: restore_signals, >>>>> start_new_session) >>>>> Feb 27 20:12:56 lpttch uwsgi[14110]: File >>>>> "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child >>>>> Feb 27 20:12:56 lpttch uwsgi[14110]: raise child_exception_type( >>>>> errno_num, err_msg, err_filename) >>>>> Feb 27 20:12:56 lpttch uwsgi[14110]: FileNotFoundError: [Errno 2] No >>>>> such file or directory: 'tests': 'tests' >>>>> >>>>> Please, can somebody help me? >>>>> >>>>> Emerson >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "pylons-discuss" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to pylons-...@googlegroups.com. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/pylons-discuss/9a78ebba-f50d-4143-9fea-550d3bce9e1e%40googlegroups.com >>>>> <https://groups.google.com/d/msgid/pylons-discuss/9a78ebba-f50d-4143-9fea-550d3bce9e1e%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>> >>>> >>>> -- >>>> >>>> Michael >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "pylons-discuss" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to pylons-...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/pylons-discuss/5cc6641f-ffe2-4b16-b26f-99edf01865f8%40googlegroups.com >>> <https://groups.google.com/d/msgid/pylons-discuss/5cc6641f-ffe2-4b16-b26f-99edf01865f8%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> >> >> -- >> >> Michael >> > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pylons-discuss+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/pylons-discuss/5a08d16d-22a2-4ed8-9438-6bb16230509a%40googlegroups.com > <https://groups.google.com/d/msgid/pylons-discuss/5a08d16d-22a2-4ed8-9438-6bb16230509a%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Michael -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/CAKdhhwFYyi_gTy3YQxTZyna5EyRb2acb1RNKZDEqAMrvLU7HJQ%40mail.gmail.com.