How to start redmine with a specific port from bash script? - ruby-on-rails

On my computer, I can start redmine by:
cd /usr/share/redmine
bundle exec rails server webrick -e production -p 3001
and this will start redmine just fine at port 3001.
If I create a bash script, it always starts at port 3000, like the parameters were ignored.
What am I doing wrong ?
This is what I have
#!/bin/bash
#exec /usr/lib/x86_64-linux-gnu/opera/opera --no-sandbox $#
cd /usr/share/redmine
# Port from settings file will be ignored either way ...
#bundle exec rails -p 3003 server webrick -e production
bundle exec rails server webrick -e production -p 3001

Quickly checked that and found that your script works perfectly fine for me, changing the port in the script also changes the port WEBrick is listening at.
So nothing wrong with the script.

Related

start unicorn on startup

I'm using Rails 4 + Nginx + Unicorn and I want that when my raspberry pi is rebooted it should run Rails application on startup.
Issue: The Nginx is running but unicorn is not running.
I've put in /etc/rc.local file the following command
cd /opt/www/RAILSAPP/current && bundle exec unicorn -E production -c config/unicorn.rb -D
but its not up when I'm rebooting. when I'm accessing the pi via ssh and run the command its working.
How can I start unicorn on startup in order to serve the rails app?

How to start passenger production when ubuntu or server starts?

I developed a Ruby On Rails application and want to deploy in production (intranet).
As of now i created an sh file to run the passenger like so:
cd /pathofmyapp
passenger start -a 0.0.0.0 -p 3000 -d -e production
cd /pathofmyapp2
passenger start -a 0.0.0.0 -p 3000 -d -e production
When the ubuntu server starts i have to execute the sh or manually start the passenger.
Is their a way to automate this so that whenever the ubuntu server starts, the command will automatically run or the ruby on rails application will start?
Thanks in advance.
You can add that to your cronjob to run the code on reboot.
#reboot cd /pathofmyapp && passenger start -a 0.0.0.0 -d -e production

How to start on booting "rvmsudo rails server" command

I am trying to configure my own "Thingspeak" server on Ubuntu 12.04 LTS virtual machine. I introduced this commands on terminal (installation on clean install of ubuntu): https://github.com/iobridge/ThingSpeak but at the final I use:
rvmsudo rails server -d -b <myip> -p 80
This command let me run Thingspeak app on port 80 as a daemon. It works well, but when the server reboot (sudo reboot for example) the thingspeak server shut down and I don't want this, I want to automatically (on booting or startup) start the thingspeak server so I don't need to manually use in terminal the rvmsudo command again.
How can I achieve this?
You can add to:
/etc/rc.local
rvmsudo rails server -d -b -p 80
or add it to /etc/init.d as well
Updating this:
sudo nano /etc/rc.local
Add the following before the exit 0 line:
cd <folder path>
rvmsudo rails server -d -b -p 80

rails server -d is not running as a background process

I currently have the below command running as a batch script
/usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby /var/rails/sandbox/script/server -p 8080 -e sandbox -d
However the log ends at trying to initialize 0.0.0.0 8080
if I remove the -d so the script is
/usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby /var/rails/sandbox/script/server -p 8080 -e sandbox
then everything runs perfect. The only issue is I am trying to detach the output so I can reuse the terminal session.
Please let me know if there is something I need to run?
Also just an fyi if I were to run the script/server alone I would have to use rvmsudo script/server -p 8080 -e sandbox -d, I get the same issue of it trying to end at 0.0.0.0 8080 but my site will not run and I will not get the message WEBrick::HTTPServer#start

How to start passenger in production environment?

I'm starting the Rails 3 application with the following command:
passenger start -a 0.0.0.0 -p 3000 -d
but how do I tell passenger to start the application in production environment?
passenger start -a 0.0.0.0 -p 3000 -d -e production
Side note: always check the help, passenger start --help would have told you the same.

Resources