heroku sequelize: command not found - mysql

I have installed sequelize cli using the following command
npm install -g sequelize-cli
It works fine on localhost
But when I deploy to heroku and try to run migrations
I get error
sequelize: command not found

As for me I was trying to run sequelize DB migration to heroku postgress database. As per earlier documentations, or maybe what you tried, was to run the command heroku run sequelize db:migrate
This however is what seems to work now heroku run npx sequelize-cli db:migrate

The package sequelize-cli is installed globally on your system so it's working on your system without any problem.
You can not run a script that is installed on your system, on the Heroku.
Since Heroku CLI is made to accomplish the operation related to Heroku dynos only i.e. you can only run commands that are predefined in Heroku CLI
To run a script on Heroku you have to define it in package and when Heroku will deploy your app it will automatically run that script.
For example:
If you want to run db:migrate using sequelize-cli then do the following steps:
add sequelize-cli as a dependency in your package.json
add migrate: "sequelize db:migrate" in the scripts.
I am not sure for what purpose you want to run this command. But to run a script on Heroku you have to define it in your package and Heroku will do the rest.

Related

How to run sass on ssh server?

I use sass in my home and office, i am working on Windows. Everything work without any issue. Problem start when i want start using sass in my home via ssh. How can i use sass to files on ssh serwer?
When i am working with sass on my local files everything working good, but when i log in to ssh via git bash and start typin
sass --watch style_scss:style_css
i see
-bash: sass comand not found
And what i figure out when i type some ruby comand I also see -bash: ruby comand not found. Both this command work when i am not on my ssh serwer. What i can do to run sass throught ssh?
That error message means sass isn't installed on your linuxserver!
Also ruby isn't installed.
If you are using ubuntu/debian use the following commands.
Ruby: sudo apt-get install ruby-full
Sass: npm install -g sass ( Requires nodejs to be installed )
For other distro's google the commands!
When joining via ssh run this command in the console to verify you have ruby and sass installed in the computer you're reaching.
sass --version
ruby -v
if these commands don't output the version of both ruby and sass, you're going to have to install them.
Can you elaborate on the process on how you connect via ssh?

Heroku hosting flask app with MySQL throwing errors

I'm new to Flask and heroku but I built a simple app and pushed it to heroku using SQLite. After migrating the app to a remote mysql db I noticed that can't get the app running because I'm getting the following error:
ImportError: No module named MySQLdb
After searching around I found that this error is because I need to install pip install mysql-python
However, my requirements.txt file already contains mysql-python
$ pip freeze
Flask==0.10.1
Flask-Login==0.3.2
Flask-Migrate==1.6.0
Flask-SQLAlchemy==2.1
Flask-Script==2.0.5
Jinja2==2.8
Mako==1.0.3
MarkupSafe==0.23
MySQL-python==1.2.5
PyYAML==3.11
SQLAlchemy==1.0.9
Werkzeug==0.10.4
...
When I run bash on heroku it says that I've already met the requirements:
~ $ heroku run bash
Running bash on blank-places-7646... up, run.9708
~ $ pip install mysql-python
Requirement already satisfied (use --upgrade to upgrade): mysql-python in ./.heroku/python/lib/python2.7/site-packages
~ $ pip freeze
alembic==0.8.3
Flask==0.10.1
Flask-Login==0.3.2
Flask-Migrate==1.6.0
Flask-Script==2.0.5
Flask-SQLAlchemy==2.1
itsdangerous==0.24
Jinja2==2.8
Mako==1.0.3
MarkupSafe==0.23
MySQL-python==1.2.5
pbr==1.8.1
python-editor==0.4
SQLAlchemy==1.0.9
stevedore==1.9.0
Werkzeug==0.10.4
~ $ pip install mysql-python --upgrade
Requirement already up-to-date: mysql-python in ./.heroku/python/lib/python2.7/site-packages
Where am I going wrong?
MySQL is an addon on Heroku so try installing ClearDB.
heroku addons:add cleardb
https://elements.heroku.com/addons/cleardb
What worked for me:
I moved the MySQL connection to a separate file and did my calculations there. Returned the results to the main routes file as a json.
I suspect that heroku doens't all MySQL connections in the same file where you have routing set up.

If a service is started during docker build, should it be running at runtime?

I have been working on setting up a self contained rails app in a single container. This means getting both rails and a data persistence service running at the same time in one container. In our case, that means mysql.
However, I ran into multiple issues getting this working, because mysql wasn't running.
During the build step, if I had RUN mysqld and then a separate RUN rake db:create step, rake would crash, because mysql was down.
So I worked around this by wrapping the two commands into a script. However, at runtime, rails would fail to startup because mysql wasn't running.
My intuition says that if mysql is started during the build, it should be available at runtime, but I did not have that experience. Starting the rails server had to be wrapped in a script with another call to mysqld.
Here's the dockerfile:
FROM ruby:2.2
RUN mkdir -p $APPDIR
WORKDIR $APPDIR
ADD Gemfile* $APPDIR/
RUN bundle install
RUN apt-get update -qq
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -qq nodejs mysql-server --no-install-recommends
RUN rm -rf /var/lib/apt/lists/* # */ broken syntax highlighting
COPY . $APPDIR
RUN script/mysql-setup.sh # contents are: mysqld_safe; rake db:create; rake db:migrate
EXPOSE 3000
CMD ["script/rails-launcher.sh"] # contents are: mysqld_safe; rails s
Do I need to do something differently in the Dockerfile? Why isn't mysql up at runtime?
My intuition says that if mysql is started during the build, it should be available at runtime
This is incorrect. Docker will start the service for you and perform the subsequent steps you've defined in the same RUN command, but then it bundles everything up into an intermediate image for subsequent commands. The image doesn't have a known state of running processes, only whatever is required for startup such as init.d scripts.
Your solution would be to use a server startup script or continue to invoke mysqld_safe as you do in your CMD line.
A good idea is to use supervisord to maintain all of your services in a non-daemon mode. Phusion also provides a nice base image with a runit initializer script.
Eventually, you'll come to see how the power of Docker lies in how you can actually break MySQL out of your Rails app container and run it in an entirely different container linked together.
The RUN Command is used to configure your image, each time it is called, a new layer is created with the results of run command. So, if you need to configure your database on the image build step, you have 2 solutions: you can call a number of command in a single RUN call, like
RUN /bin/bash -c "mysqld_safe" && "rake db:create" && "rake db:migrate"
Or via call of single script, as you did.
In both cases, you have to inderstand, that the fact, you runned something during the image build, it'll not run automatcally on the container start up. So, you have to start your database server manually on container start up.

How to connect to Openshift Mysql database with PHPstorm?

Not succeed after reading stackoverflow and openshift docs. This is the settings and the error message:
http://primere-creatives.rhcloud.com/testing/2014-05-06_11-24-33.jpg
Not sure, have I do port forwarding?
Thanks!
To connect to the MySQL cartridge running on OpenShift you have to first run rhc port-forward command. rhc is the command-line client that you can use to work with OpenShift. It is a ruby gem that you can install using gem install rhc command. Refer to https://www.openshift.com/blogs/getting-started-with-port-forwarding-on-openshift and https://www.openshift.com/blogs/set-up-local-access-to-openshift-hosted-services-with-port-forwarding

bundler: not executable: rake

I'm in the process of setting up JRuby 1.7 in a ubuntu vagrant box to work with torquebox. I'm using the torquebox-remote-deployer gem to deploy the archive file and the app stuff to the virtual machine. Now, when the gem tries to execute bundle exec rake db:migrate, I get the following error:
bundler: not executable: rake
Now, when i check in the vendor/bundle/jruby/1.9/bin directory, rake and all the other needed executables are there. I've also tried running the bundle command through the local jruby install to ensure it is called properly, but I get the same result
/opt/jruby/bin/jruby -S bundle exec rake db:migrate
Any suggestions? If you need more info, just ask.
So is the rake file that's there actually marked as executable?
Not sure how you'd end up in that situation to begin with but the error message seems to be saying that 'rake' itself is there but just not marked executable (+x).
If same question will be for rails script file solution will be:
Just update file permission to executable. It worked for me.
chmod 777 -R script/filename.rb
Cheers!
This is due to a "bug" with jar.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6194856
I ended up creating a separate ruby script for fixing permissions that I invoke with torquebox:remote:exec["bundle exec jruby path/to/script"].