简体   繁体   中英

Appassembler `run.as.user.envvar` when running locally

I'm using appassembler plugin to generate my application structure successfully. Because my application is started from init.d script I amended the configuration so the application runs under serveruser rather than root :

<generatorConfigurations>                         
    <generatorConfiguration>                                               
            <property>                            
                <name>run.as.user.envvar</name>   
                <value>serveruser</value> <-- Here the user is set -->         
            </property>                           
        </configuration>                          
    </generatorConfiguration>                     
</generatorConfigurations>

This works fine when deployed to server but I want to be able to run the application locally after running mvn clean package . And in that case it tries to su (switch user) to serveruser which doesn't exist on my local machine. Is there any best practice around this?

The ultimate goal is to be able:

  1. Build locally and run via the generated scripts
  2. Package the same generated project structure deploy it and run from there

My current solution is to provide Maven profile. If local profile is set the property is blank and the run.as.user.envar is not set so the start script launches under current user.

If no profile is set a default profile is set and this set the production user so it is not possible to launch it locally but you can launch on server.

Not 100% but works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM