# Running a web application as daemon



## amr (Jan 3, 2021)

I've cloned odoo ERP using git, in directory /home/amr/erp/odoo. And created a startup script "odoo" in /usr/local/etc/rc.d
My concern is not to run the rc script as a root user so I've created a non login user by the following command:

```
pw adduser odoo -d /nonexistent -s /usr/sbin/nologin -c "Odoo ERP"
```
My problem is that when I run the app with "odoo" user it fails but when I run it with "amr" user it starts.
So how I can make the app run with "odoo" user, here my rc script:

```
#!/bin/sh
#
# PROVIDE: odoo
# REQUIRE: DAEMON
# KEYWORD: shutdown
#

. /etc/rc.subr

name="odoo"
user="odoo"
rcvar="odoo_enable"
odoo_command="/home/amr/erp/odoo/.venv/bin/python /home/amr/erp/odoo/odoo-bin -c /home/amr/erp/odoo/odoo.conf --without-demo=all"

pidfile="/var/run/${name}.pid"
command="/usr/sbin/daemon"                                                                              
command_args="-P ${pidfile} -u ${user} -r -f ${odoo_command}"                                            
                                                                                                         
load_rc_config "${name}"                                                                                
: "${odoo_enable:=no}"                                                                                  
                                                                                                         
run_rc_command "$1"
```


----------

