cvitter / mattermost-standup-slash

Flask adaptation of George Goldberg's AWS Lambda based Standup Slash command: https://grundleborg.github.io/posts/mattermost-custom-slash-command-aws-lambda/
MIT License
7 stars 1 forks source link

Support for basic Config file with a couple of formatting options. #4

Closed howaminotme closed 6 years ago

howaminotme commented 6 years ago

Config file which supports setting:

Here are some of the examples.

screen shot 2018-08-14 at 2 12 54 pm
cvitter commented 6 years ago

Awesome, let me test this on my cluster on this end.

cvitter commented 6 years ago

@howaminotme I cloned the repo and tested it on my end:

:~/mattermost-standup-slash$ sudo python standup.py 
Traceback (most recent call last):
  File "standup.py", line 80, in <module>
    app.run(host='0.0.0.0', port=listen_port, debug=debug_mode)
  File "/home/sales-demo/.local/lib/python2.7/site-packages/flask/app.py", line 841, in run
    run_simple(host, port, self, **options)
  File "/home/sales-demo/.local/lib/python2.7/site-packages/werkzeug/serving.py", line 748, in run_simple
    raise TypeError('port must be an integer')
TypeError: port must be an integer

This is on Ubuntu 16.04 LTS.

howaminotme commented 6 years ago

@cvitter interesting - I am on 16.04 as well and not seeing that error.

What version of python are you using? nvm looks like you are on 2.7 as well from your dump.

I bet it has to do with the Flask Version.

regardless - try modifying standup.py, the last declaration, to look like this:

if __name__ == '__main__': app.run(host='0.0.0.0', port=int(listen_port), debug=debug_mode)

that should force it to be an integer.

I confirmed that it works on me end. If it works for you I will update my PR to fix.

cvitter commented 6 years ago

Yes, that gets it to start however also finding that even though debug_mode = False the debbuger is active when it launches:

$ sudo python standup.py 
 * Running on http://0.0.0.0:5004/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 222-774-744
howaminotme commented 6 years ago

What version of Flask are you running in your environment?.

My suspicion is that whatever object type() ConfigParser creates when it reads in the config file is not what your version of Flask is expecting, but that the version I am using may be ok with it. Basing that almost entirely on the error we saw with the port value.

cvitter commented 6 years ago

As a test I upgraded to 1.0.2 (was running an older version 0.12) and getting this now:

$ sudo python standup.py 
 * Serving Flask app "standup" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://0.0.0.0:5004/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 413-663-436

Will do some more research when I have a chance today to see if I help figure this out.

howaminotme commented 6 years ago

Hey @cvitter I looked at my end and I was seeing that same behavior - I tried some formatting options but couldnt get the debug_mode from config parser to pass in correctly. After reading the Flask Documentation It seems like that config follows the value set via "ENV='Production'".

For now I removed the debug_mode variable from the config file and manually set the mode to false in app.run.

That seems to have fixed the issue.