Azure / wordpress-linux-appservice

MIT License
96 stars 65 forks source link

Startup Command Field #139

Open pauljohnstone opened 3 months ago

pauljohnstone commented 3 months ago

Has there been any further issue with the Startup Command Field? I need to apply rewrite rules, which from my understanding need to be applied to nginx.conf

Test rewrite rule below: server { listen 80; server_name your-domain.azurewebsites.net; location /Lib/abc/ { rewrite ^/Lib/abc/(.*)$ /Lib/ABC/$1 break; } }

The startup.sh file is located in the /home/dev/ when reviewing the file it's no script at all, which makes me think that the script is not being applied from the startup command field and is being ignored.

If this is still the case then what is the workaround solution?

Note on the following link https://github.com/Azure/wordpress-linux-appservice/blob/main/WordPress/running_post_startup_scripts.md

Note: As of September 2022, the startup script MUST exist at (/home/dev/startup.sh). Further, the value of the Startup Command field in the Azure Portal found under [App Service for Linux] > Configuration > General Settings > Startup Command is ignored. The Azure team is aware of this and working to make this flow more natural.

samrueby commented 3 months ago

The startup.sh file is located in the /home/dev/ when reviewing the file it's no script at all, which makes me think that the script is not being applied from the startup command field and is being ignored.

I am trying to understand "it's no script at all". By default, it's an empty file. It's empty because it's free for you to use. If you put commands in this file, they will execute when the container boots.

pauljohnstone commented 3 months ago

Hi @samrueby,

Apologies for any confusion. I've been trying to clarify the process for applying a script within the startup command field in the Azure portal. It seems that when you apply a script, it should ideally write to the current startup.sh file located under the home/dev folder.

As you mentioned, manual addition of the script to the startup.sh file is necessary for it to take effect. Additionally, copying the nginx default.conf file to the /home directory is required for applying updates. Consequently, the startup.sh script will handle copying and replacing any changes to the nginx directory.

Here's a snippet of the script:

echo "Custom script" cp /home/default.conf /etc/nginx/conf.d/default.conf /usr/sbin/nginx -s reload

Note that the echo statement has be added to review logs to confirm whether or not the startup script is being executed.

In recent weeks, upon review, I discovered that the current issue with this particular image lies in how supervisord is configured, which explains why the startup script when applied to the startup command field is being ignored.

samrueby commented 3 months ago

Ah, yes. On that same page is documented:

Further, the value of the Startup Command field in the Azure Portal found under [App Service for Linux] > Configuration > General Settings > Startup Command is ignored. The Azure team is aware of this and working to make this flow more natural.

So it's a known issue.

Glad like you were able to get through the issue.