-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeep-odoo-running.html
128 lines (106 loc) · 7.1 KB
/
keep-odoo-running.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Keep Odoo running, easily</title>
<link rel="stylesheet" href="http://pouyamn.github.io/theme/css/main.css" />
<link href="http://pouyamn.github.io/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="Odoo Demystification Atom Feed" />
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body id="index" class="home">
<header id="banner" class="body">
<h1><a href="http://pouyamn.github.io/">Odoo Demystification </a></h1>
<nav><ul>
<li class="active"><a href="http://pouyamn.github.io/category/odoo.html">odoo</a></li>
<li><a href="http://pouyamn.github.io/category/pelican.html">Pelican</a></li>
</ul></nav>
</header><!-- /#banner -->
<section id="content" class="body">
<article>
<header>
<h1 class="entry-title">
<a href="http://pouyamn.github.io/keep-odoo-running.html" rel="bookmark"
title="Permalink to Keep Odoo running, easily">Keep Odoo running, easily</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2016-01-12T11:26:00">
Tue 12 January 2016
</abbr>
<address class="vcard author">
By <a class="url fn" href="http://pouyamn.github.io/author/pouya-mn.html">Pouya MN</a>
</address>
<p>In <a href="http://pouyamn.github.io/category/odoo.html">odoo</a>. </p>
<p>tags: <a href="http://pouyamn.github.io/tag/odoo.html">odoo</a><a href="http://pouyamn.github.io/tag/openerp.html">openerp</a><a href="http://pouyamn.github.io/tag/general.html">general</a></p>
</footer><!-- /.post-info --> <p>A few months ago we had this problem with odoo, the server was sometimes jumping out; quiting with no error, sometimes some momory error. All we had to do was running it agian. It was happening about every 12-48 hours normally but some times every 2-3 hours. It was a pain in the butt, so I made an easy solution that is still working. It means no user complains anymore ;).</p>
<p>A bit of history, I was using ssh to connect to the server and run it with this command:</p>
<div class="highlight"><pre>nohup ./openerp-server &
</pre></div>
<p>please note that I ran ./openerep-server directly, whenever I close ssh connection the server would quit. </p>
<p>The solution was a shell script. At first, I tried to check if odoo is running and if not run it. I started with this command:</p>
<div class="highlight"><pre><span class="c">#NOT WORKING</span>
ps aux | grep openerp <span class="o">||</span> <span class="nb">echo</span> <span class="s2">"not running"</span>
</pre></div>
<p>Demystification:</p>
<p><strong>ps aux</strong> <em>list process and send output to screen</em>
<strong>grep openerp</strong> <em>filter process with openerp in them.</em>
<strong>|| echo "not running"</strong> <em>if the result(exit code) of grep is false, print 'not found'</em> </p>
<p>Easy,but wait my own command is always fetch by grep! the result is </p>
<div class="highlight"><pre><span class="n">my_user</span> <span class="mi">4220</span> <span class="mf">16.4</span> <span class="mf">4.9</span> <span class="mi">1080324</span> <span class="mi">400516</span> <span class="n">pts</span><span class="o">/</span><span class="mi">0</span> <span class="n">Sl</span> <span class="mo">07</span><span class="o">:</span><span class="mi">54</span> <span class="mi">21</span><span class="o">:</span><span class="mi">15</span> <span class="n">python</span> <span class="p">.</span><span class="o">/</span><span class="n">openerp</span><span class="o">-</span><span class="n">server</span>
<span class="n">my_user</span> <span class="mi">32186</span> <span class="mf">0.0</span> <span class="mf">0.0</span> <span class="mi">7836</span> <span class="mi">884</span> <span class="n">pts</span><span class="o">/</span><span class="mi">1</span> <span class="n">S</span><span class="o">+</span> <span class="mi">10</span><span class="o">:</span><span class="mo">04</span> <span class="mi">0</span><span class="o">:</span><span class="mo">00</span> <span class="n">grep</span> <span class="n">openerp</span>
</pre></div>
<p>So the exit code of grep is always greater than 0 or logically speeking, it is <em>True</em>. I cannot understad wether odoo is running. I had to filter out 'grep' line, or keep odoo lines only: </p>
<div class="highlight"><pre>ps aux | grep openerp |grep python <span class="o">||</span> <span class="nb">echo</span> <span class="s2">"not running"</span>
</pre></div>
<p>Demysitification:
<em>firstly, filter lines with openerp in them then filter the results again by:</em>
<strong>grep python</strong> <em>yes, nasty 'grep' line has no python in it! ;)</em></p>
<p>now it works fine.
For the next step I wrote a bash script starting like:</p>
<div class="highlight"><pre><span class="k">if</span> <span class="o">[</span>ps aux | grep openerp | grep python<span class="o">]</span>
...
</pre></div>
<p>But then it downed on me that the solution is much easier, the final script is:</p>
<div class="highlight"><pre>run-odoo.sh:
<span class="nb">cd</span> ~/odoo <span class="c">#replace it with your odoo folder</span>
<span class="k">while</span> <span class="o">[</span> : <span class="o">]</span>
<span class="k">do</span>
./openerp-server
sleep 3
<span class="k">done</span>
</pre></div>
<p>just run it the same as before:
```bash
nohup ./run-odoo.sh &
````
clean and easy! </p>
</div><!-- /.entry-content -->
</article>
</section>
<section id="extras" class="body">
<div class="blogroll">
<h2>blogroll</h2>
<ul>
<li><a href="http://odoo.com/">Odoo</a></li>
<li><a href="http://fshahy.github.io/">Odoo made Einfach</a></li>
</ul>
</div><!-- /.blogroll -->
<div class="social">
<h2>social</h2>
<ul>
<li><a href="http://pouyamn.github.io/feeds/all.atom.xml" type="application/atom+xml" rel="alternate">atom feed</a></li>
<li><a href="https://github.com/pouyamn/">My github page</a></li>
<li><a href="https://tr.linkedin.com/in/pouyamn">My linked-in profile</a></li>
</ul>
</div><!-- /.social -->
</section><!-- /#extras -->
<footer id="contentinfo" class="body">
<address id="about" class="vcard body">
Proudly powered by <a href="http://getpelican.com/">Pelican</a>, which takes great advantage of <a href="http://python.org">Python</a>.
</address><!-- /#about -->
<p>The theme is by <a href="http://coding.smashingmagazine.com/2009/08/04/designing-a-html-5-layout-from-scratch/">Smashing Magazine</a>, thanks!</p>
</footer><!-- /#contentinfo -->
</body>
</html>