1

On Azure Linux App service, while deploying a flask app i get following error:

2019-05-12T13:07:29.931475061Z A P P   S E R V I C E   O N   L I N U X
2019-05-12T13:07:29.931478561Z 
2019-05-12T13:07:29.931481661Z Documentation: http://aka.ms/webapp-linux
2019-05-12T13:07:29.931484961Z 
2019-05-12T13:07:30.016820049Z Starting OpenBSD Secure Shell server: sshd.
2019-05-12T13:07:30.026671394Z Site's appCommandLine: startup.sh
2019-05-12T13:07:30.055028087Z Checking of startup.sh is a file
2019-05-12T13:07:30.082487648Z App command line is a file on disk
2019-05-12T13:07:30.082508249Z App command line is a shell script, will execute this script as startup script
2019-05-12T13:07:30.082513649Z Launching oryx with: -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -userStartupCommand startup.sh
2019-05-12T13:07:30.082479048Z Oryx Version : 0.2.20190401.5, Commit: c7bcd3a2b802e109512924fbcf208bf77bf6cc6e
2019-05-12T13:07:30.082553451Z 
2019-05-12T13:07:30.851365669Z Writing output script to '/opt/startup/startup.sh'
2019-05-12T13:07:30.893829956Z Using packages from virtual environment 'antenv' located at '/home/site/wwwroot/antenv'.
2019-05-12T13:07:30.904225020Z /opt/startup/startup.sh: 39: /opt/startup/startup.sh: startup.sh: not found

The startup.sh file is in /site/wwwroot and the content is as follows:

#!/bin/bash
source antenv/bin/activate
gunicorn --bind=0.0.0.0 --timeout 600 app:app

Any idea on what is leading to this error?

Zedi10
  • 85
  • 2
  • 10
  • [Why is #!/usr/bin/env bash superior to #!/bin/bash?](https://stackoverflow.com/q/21612980/608639) – jww May 12 '19 at 15:21

2 Answers2

2

We had the same problem when there was a problem with the line endings in the file, because it was edited in Notepad. Try the sed editor to fix it: sed -i -e 's/\r$//' <path_to_sh_file>

lienn
  • 102
  • 7
  • Absolutely brilliant! I've been working on this for 3 hours without any progress. Ran the one command above and it fixed it all. That's amazing! +1 my friend. – War10ck Sep 30 '21 at 15:42
  • yes, I had an extra line break in my file. Just deleted the line and it now works. – Christopher May 17 '22 at 15:44
1

You should be able to customize the Python application command by following this document: https://docs.microsoft.com/en-us/azure/app-service/containers/how-to-configure-python#customize-startup-command

Example (This can be added in the Startup Command): gunicorn --bind=0.0.0.0 --timeout 600 hello:myapp

To understand how the command works, you can take a look into the init_container.sh script here: https://github.com/Azure-App-Service/python/blob/master/3.7.0/init_container.sh

Gaurav Kumar
  • 104
  • 7