Play change RUNNING_PID file path - scala

I am trying to store the RUNNING_PID file at /var/run instead of root directory.
Tried all the options suggested at:
Another SO question about the subject
and the solution play suggest in their documnetation: Play additional configuration
Yet when I start my app the RUNNING_PID file is created in root directory and the /var/run/play.pid remains empty

Put
play.server.pidfile.path=/var/run/RUNNING_PID
in your application.conf

Create a "play" user and group in Linux, so it runs in a secure fashion.
In the SystemD service file, and within [Service] area use:
[Service]
# Create the Directory /var/run/play (which Play will have write permissions to)
RuntimeDirectory=play
RuntimeDirectoryMode=0710
User=play
Group=play
In the ExecStart, specifically pass the system property "pidfile.path":
ExecStart=/opt/play-1.0.0/bin/play -Dconfig.file=/path/to/my/application.conf \
-Dpidfile.path=/var/run/play/play.pid

Below worked for me in Play 2.8 (🍾🍾):
Add this property to you application.conf present in conf directory:
play.server.pidfile.path=/var/run/RUNNING_PID
Note: It will try to create a file under /var/run and if you don't want/have the right to write to the filesystem i.e you are running your application in Kubernetes (1.20) pod change it to /dev/null.
play.server.pidfile.path=/dev/null
Hope this helps, Cheers (🍾🍾).

Related

How do I make a golem app appear at a specific URL route

We let the golem package automatically create a Dockerfile for us and can run the docker image and see the app at the root directory: http://localhost:3838/?...
But we would like the app to appear in a subdirectory like http://localhost:3838/myApp/v1/?... so that we can set up the necessary proxying for Apache and have this and other apps all available from a single server.
We can manually edit the Dockerfile to copy a shiny-server.conf file with the following information:
# Define a server that listens on port 3838
server {
listen 3838;
# Define a location at the base URL
location /myApp/v1/ {
# Host the directory of Shiny Apps stored in this directory
site_dir /srv/shiny-server;
# Log all Shiny output to files in this directory
log_dir /var/log/shiny-server;
}
}
The above solution feels like a hack and we are hoping there is functionality inside of golem that will allow us to set the subdirectory at which the app will appear.
Unfortunately there is no way to include an nginx configuration inside the Dockerfile programmatically: {golem} tries to help with the creation of the file, but some things still need to be done manually.
Also, note that {golem} doesn't create a Dockerfile with a shiny server in it, it creates a standalone docker image that launches the app, so there is no shiny server running, just an R process. {shiny} being what it is, there is no way to natively run it on a given path, it's always at the root, on a port.
That being said, what you can do is either edit the dockerfile so that it also bundle nginx (or any other load balancer), so that you can serve the app on a path, or serve your application on another port, using the port argument of add_dockerfile(): that might be easier to configure it with you Apache proxy.
Colin

Can't access non-public directories on local FS in streamsets pipeline creator

New to streamsets. Following the documentation tutorial, was getting
FileNotFound: ... HADOOPFS_14 ... (permission denied)
error when trying to set the destination location as a local FS directory and preview the pipeline (basically saying either the file can't be accessed or does not exist), yet the permissions for the directory in question are drwxrwxr-x. 2 mapr mapr. Eventually found workaround by setting the destination folder permissions to be publicly writable ($chmod o+w /path/to/dir). Yet, the user that started the sdc service (while I was following the installation instructions) should have had write permissions on that directory (was root).
I set the sdc user env. vars. to use the name "mapr" (the owner of the directories I'm trying to access), so why did I get rejected? What is happening here when I set the env. vars. for sdc (because it does not seem to be doing anything)?
This is a snippet of what my /opt/streamsets-datacollector/libexec/sdcd-env.sh file looks like:
# user that will run the data collector, it must exist in the system
#
export SDC_USER=mapr
# group of the user that will run the data collector, it must exist in the system
#
export SDC_GROUP=mapr
So my question is, what determines the permissions for the sdc service (which I assume is what is being used to access FS locations by the streamsets web UI)? Any explaination or links to specific documentation would be appreciated. Thanks.
Looking at the command ps -ef | grep sdc to examine who the system thinks the owner of the sdc process really is, found that it was listed as:
sdc 36438 36216 2 09:04 ? 00:01:28 /usr/bin/java -classpath /opt/streamsets-datacollector
So it seems that editing sdcd-env.sh did not have any effect. What did work was editing the /usr/lib/systemd/system/sdc.service file to look like (notice that have set user and group to be the user that owns the directories to be used in the streamsets pipeline):
[Unit]
Description=StreamSets Data Collector (SDC)
[Service]
User=mapr
Group=mapr
LimitNOFILE=32768
Environment=SDC_CONF=/etc/sdc
Environment=SDC_HOME=/opt/streamsets-datacollector
Environment=SDC_LOG=/var/log/sdc
Environment=SDC_DATA=/var/lib/sdc
ExecStart=/opt/streamsets-datacollector/bin/streamsets dc -verbose
TimeoutSec=60
Then restarting the sdc service (with systemctl start sdc, on centos 7) showed:
mapr 157013 156955 83 10:38 ? 00:01:08 /usr/bin/java -classpath /opt/streamsets-datacollector...
and was able to validate and run pipelines with origins and destinations on local FS that are owned by the user and group set in the sdc.service file.
* NOTE: the specific directories used in the initial post are hadoop-mapr directories mounted via NFS (mapr 6.0) (though the fact that they are NFS should mean that this solution should apply generally) hosted on nodes running centos 7.

Capistrano 3 move log directory

how can I change the directory where capistrano puts its log files? I could not find in the docs.
Currently the logs appear in myapp/log/... on my dev machine. However, since I am using laravel, and there is a log directory myapp/storage/logs I would like capistranos logs to appear here as well.
Do you mean the capistrano.log file that is created and appended to whenever you deploy?
You can specify the location by adding the following to deploy.rb:
set :format_options, log_file: "storage/logs/capistrano.log"
This tells Airbrussh (the default logging implementation in Capistrano 3.5.0+) where to place the log file. More information here: https://github.com/mattbrictson/airbrussh#configuration

Capistrano mkdir: cannot create directory

I'm trying to use Capistrano (for the first time) to deploy a website. My web hosting is with MediaTemple. Where the dir structure for a website looks like this:
domains/site.com/html/index.html
It looks like Capistrano's default deployment tries to create a var/www directory to place your application inside.
I'm getting this error when trying to run cap production deploy:
mkdir: cannot create directory `/var/www': Permission denied
I assume I don't have the privileges to create these folders, is there a way around this instead of manually creating them?
Also, would the var/www structure be recommended, or would it be worth dumping my application in domains/site.com?
This is my first experience with Capistrano, so any help with this is appreciated. Thanks in advance!
In a default Capistrano deployment setup, there is a commented line that looks like:
# Default deploy_to directory is /var/www/my_app
# set :deploy_to, '/var/www/my_app'
You will want to uncomment the set line and change the path to be the location you want your application deployed to.

Write a simple mod_perl handler

I want to write a simple mod_perl handler which returns the local time like described on this page (http://perl.apache.org/docs/2.0/user/handlers/intro.html), but where have I to locate this file to access it.
I'm using Ubuntu but don't have a directory called MyApache2. So where to locate this file to try the functionality?
This is just an example. You need to create the files yourself. (You'll see your example refers to "file:MyApache2/CurrentTime.pm").
mkdir -p example-lib/MyApache2
touch example-lib/MyApache2/CurrentTime.pm
Then paste the contents from the example into the file you just created.
In order for this to run under mod_perl, you'll also have to let the server know where your MyApache2 is located. You should be able to add something like this to your Apache config:
PerlSwitches -I/path/to/example-lib
Don't forget to restart Apache before you test this out.